Project Overview
This project creates a humane dog bark deterrent that uses ultrasonic sound to discourage excessive barking. The system activates only when motion is detected, saving battery life and preventing constant noise. When the sensor detects a dog (or person), it emits a high-frequency sound (25-30 kHz) that is unpleasant to dogs but inaudible to humans.
Difficulty: Intermediate
Estimated time: 2-3 hours
Estimated cost: $25-35
How It Works
A PIR sensor detects motion (the dog approaching). When motion is detected, the system activates an ultrasonic transducer that emits a high-frequency tone. Dogs find this sound unpleasant and learn to associate the area with the sound, eventually reducing barking behavior. An optional sound sensor can be added to only activate when barking is actually occurring.
Materials Needed
- Arduino Nano or ESP32 (1)
- HC-SR501 PIR sensor (1)
- Ultrasonic transducer (25-30 kHz, e.g., Murata MA40S4S)
- ULN2003 Darlington array or MOSFET (to drive transducer)
- Sound sensor module (LM393-based, optional)
- LED for status indication
- 220Ω resistor
- Jumper wires
- Power supply (5V 1A)
- Weatherproof enclosure (if outdoor use)
Circuit Diagram
Connection Table
| Component |
Pin |
Arduino Pin |
PIR Sensor |
VCC
5V
PIR Sensor |
GND
GND
PIR Sensor |
OUT
Digital Pin 2
Ultrasonic Transducer (+) |
–
Digital Pin 9 (via ULN2003)
Ultrasonic Transducer (-) |
–
GND
Sound Sensor |
DO
Digital Pin 3
Status LED |
Anode
Digital Pin 13 (via 220Ω)
表
Arduino Code
// PIR Dog Bark Stopper
const int pirPin = 2;
const int ultrasonicPin = 9;
const int soundSensorPin = 3;
const int ledPin = 13;
const int halfPeriod = 20;
unsigned long lastTriggerTime = 0;
const unsigned long deterrentDuration = 3000;
const unsigned long cooldownPeriod = 60000;
bool deterrentActive = false;
unsigned long deterrentStart = 0;
void setup() {
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(ultrasonicPin, OUTPUT);
pinMode(soundSensorPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(ultrasonicPin, LOW);
digitalWrite(ledPin, LOW);
Serial.println("Dog Bark Stopper Ready");
delay(60000);
}
void generateUltrasonicTone() {
for (int i = 0; i < 1000; i++) {
digitalWrite(ultrasonicPin, HIGH);
delayMicroseconds(halfPeriod);
digitalWrite(ultrasonicPin, LOW);
delayMicroseconds(halfPeriod);
}
}
void activateDeterrent() {
if (millis() - lastTriggerTime > cooldownPeriod) {
deterrentActive = true;
deterrentStart = millis();
lastTriggerTime = millis();
digitalWrite(ledPin, HIGH);
while (millis() - deterrentStart < deterrentDuration) {
generateUltrasonicTone();
}
digitalWrite(ledPin, LOW);
deterrentActive = false;
}
}
bool isBarking() {
return digitalRead(soundSensorPin) == HIGH;
}
void loop() {
bool motionDetected = digitalRead(pirPin) == HIGH;
bool barking = isBarking();
if (motionDetected) {
activateDeterrent();
}
delay(100);
}
Installation Steps
- Assemble circuit on breadboard and test with oscilloscope
- Test with a known dog to verify reaction (look for ear perk, head tilt)
- Adjust frequency for different dogs (20-30kHz)
- Mount unit where the dog frequents at appropriate height (0.5-1m)
- Observe behavior over several days to see if barking reduces
Safety Considerations
- This device is meant to discourage excessive barking, not to punish
- The deterrent should only activate briefly when motion is detected
- The sound should be inaudible to humans; if you can hear it, the frequency is too low
- Not for use on puppies (very young dogs may be more sensitive)
- Check local regulations regarding ultrasonic devices
Project Extensions
- Add sound sensor to only trigger when barking is actually occurring
- Add ESP32 to send notifications when the deterrent activates
- Track how often the device activates to measure barking frequency
- Add Bluetooth to manually trigger from phone
- Add water sprayer for stubborn dogs (less humane)
Conclusion
This humane bark deterrent can help reduce excessive barking without causing pain or distress. Combined with positive reinforcement training, it can be an effective tool for managing nuisance barking.