Introduction: Bark 1.0 - Makes Dog Barking Sounds When There Is Motion in Front of the Door
This is the prototype of a fun project idea I have had from quite some time now. This device is intended to protect your house when you are away. Bark is a small device you mount onto your front door. Just like you would do with a smart doorbell, except this goes on the side of the door inside the house. It has a RADAR motion sensor whose signals can penetrate the door and detect motion outside. When it detects motion, it produces a loud sound of a dog barking, giving the illusion that a dog is in the house. You can say it is a home security alarm with a dog bark instead of a siren. But the advantage this has over other kinds of motion sensor alarms is that this requires almost no wiring whatsoever.
With a standard motion sensor based alarm, you would need to mount the sensor outside the house. If there are components inside the house, you would have to find a way to pass the wires through the walls into your house. But Bark is an extremely portable little device. All you need to do is stick it onto your door, and you’re done. Well, almost. This is a prototype that proves the working of the concept. There are still a few things to iron out.
In this Instructable, I will walk you through how I made this working prototype.
Supplies
A microcontroller (preferably Arduino UNO/NANO or esp3266/esp32) Amazon Link
RCWL-0516 RADAR motion sensor Amazon Link
Micro SD card reader module Amazon Link
Audio amplifier circuit Amazon Link
A 5-10W speaker driver Amazon Link
9v power supply/rechargeable batteries
Male-Female Jumper wires
Self-tapping screws
Step 1: Working Principle
The circuit and Arduino program will be much easier to understand if we know how everything works. Let me explain them in steps:
- Detecting motion: The RADAR sensor is extremely sensitive to motion. The biggest advantage of a RADAR sensor over a standard PIR motion sensor is that it works through barriers like wood. Typically, its range is between 5 and 8 meters. But through a 2 cm piece of wood, its range reduces to a meter or lower. But that should be fine for our case. We don’t want the device to start barking when random strangers are walking past our house. As soon as there is slight motion within the sensor's range, its OUT pin sends out a digital signal.
- Producing the barking sound: The barking sound is downloaded from the internet as a wav file. Unfortunately, most microcontrollers have too little memory to store the audio file. So, we will use a cheap micro SD card reader and a micro SD card to store the audio file. As soon as the Arduino receives a motion signal from the RADAR sensor, the audio file in the SD card gets played.
- Amplifying the audio: The output of the Arduino is not high enough to produce a loud sound. It is comparable to the amount of loudness a pair of headphones produce. To increase the volume to the level of a real dog, we will first send the audio signal to an audio amplifier. The output of the amplifier will be connected to a loudspeaker.
Step 2: Testing the RADAR Sensor
The RCWL-0516 RADAR motion sensor is the star of the show. Before making the whole circuit, I wanted to make sure the sensor would work through my 2 cm thick wooden door. So I created a test rig for it.
First, I took a block of wood that was almost the same thickness as my front door. Then, I stuck the RADAR sensor onto it using masking tape.
I then made a simple circuit by connecting an LED to the sensor’s output, and a 3.3v power supply to it’s VIN and GND pins. I got the 3.3v power supply from an Arduino.
Then I placed the wood upright such that the face with the RADAR sensor was away from me. Now, if I moved in front of the blank face of the wood and the LED lit up, the entire thing would be a success. And guess what? It did exactly that! It seemed to be quite unbelievable. The sensor was picking my motion up through a 2 cm thick block of wood. It makes sense, as radio waves can easily pass through barriers like wood, but seeing it in action was very exciting.
Step 3: Programming the Arduino
Firstly, I made sure I had the necessary libraries installed. The libraries required for this project are — SD, SPI, and TMRpcm.
The code is in fact quite small and easy to understand.
In the setup() function, I assigned pin 9 as the speaker output pin. Then I wait until the SD card is detected using SD.begin() function. After that, I set a volume of 2. This number can be experimented upon. But for the audio amplifier I had, a volume of 2 was perfect. Then I have added a 1-minute delay before the loop function is executed. This way, I will have time to lock the door and go out of its sensing range.
In the loop() function, I check if pin 5 is receiving any input. Pin 5 is where the output of the RADAR sensor will be connected. If it receives a signal from the sensor, the tmrpcm library is used to play the audio file from the SD card. In this case, I have named it bark.wav. After playing the whole audio once, I set a delay of 5 seconds. I didn’t want the audio to play continuously when there is motion.
Attachments
Step 4: Preparing the Audio File
The audio file needs to be processed before the Arduino can read it. I have added the processed audio file in this step as an attachment. If you are using the same file, you can ignore this step.
First, I downloaded the dog barking sound as an MP3 file. Then, I used this tool to convert the audio to WAV. There are also a few more changes to be made to the audio.
- Change bit resolution: 8
- Change audio frequency: 16000
- Change audio channels: Mono
- Change PCM format: U8
Then I saved the .wav file with the name bark.wav. I would suggest keeping the filename within 4 characters, as sometimes the SD card reader doesn’t work with larger names.
Step 5: Formatting the SD Card
The SD card needs to be formatted to FAT. I used this tool
Use it at your own risk. I have used it and it worked fine. But since I am not the creator of the software, I cannot guarantee it will work for everyone without any problems. Install the tool by clicking on setup.exe. Once installed, open the software, select your drive and click on formatted. Then, copy the bark.wav audio file into the SD card.
You can use any other tool as well. Make sure to format the SD card to FAT.
Step 6: Making the Circuit Connections
Make the circuit connections only after you have uploaded the code to your Arduino board. I am using an esp8266 instead of an Arduino UNO since it smaller and fits in my cardboard housing well. Everything remains the same no matter what microcontroller you use. I referred this image to map the Arduino GPIO pins to esp8266. But I will explain the steps for an Arduino here.
The circuit might look overwhelming at first. But once broken down to individual components, it should be fairly easy to understand.
Step 7: Connecting the SD Card Reader
First, I inserted the micro SD card into the card reader. Then I made the following connections:
- CS to pin 10 of Arduino
- SCK to pin 13 of Arduino
- MOSI to pin 11 of Arduino
- MISO to pin 12 of Arduino
- VCC to 5v pin of Arduino
- GND to GND of Arduino
Step 8: Connecting the RADAR Sensor
- VIN to 3.3v pin of Arduino (The circuit diagram shows 5v pin, but that is a mistake)
- OUT to pin 5 of Arduino
- GND to GND of Arduino
Step 9: Connecting the Audio Amplifier
The audio input pins are connected to pin 9 and GND of Arduino. Power + and - are connected directly to the 9v power supply. The audio output pins are connected to the 6w speaker. The connections will remain the same for all audio amplifiers. If you are using a stereo amplifier, you can use one channel of the amp and leave the other empty.
Step 10: Power Supply
To make the device truly portable, I recommend using rechargeable Li-ion batteries to power the circuit.Make sure to use a suitable charging module like this one to properly charge the batteries. And don’t forget to add a switch to power it ON/OFF.
But since this is a prototype, I decided to directly power the circuit using a 9v power supply. Not ideal since I need a lot of loose wire to accommodate for the opening of the door, but hey, at least it works.
Step 11: Assembly
I used a cardboard box to house all the circuitry. This is because it’s just a proof of concept. For the final build, I plan on designing a 3D printable case using Fusion 360. But as of now, cardboard it is.
All the components are placed inside the housing except for the RADAR sensor and speaker. I attached the radar sensor to the back face of the cardboard using a tiny piece of double-sided foam tape. I made a few tiny holes through which the sensors pins can pass into the cardboard. While you can attach the RADAR sensor inside the cardboard as well, I didn’t want to add the cardboard’s thickness to my already thick wooden door between the sensor and the outside world.
I cut a big hole on the front face to mount the speaker driver using self-tapping screws. They seem to hold the heavy speaker fine, especially since I added two more layers of cardboard to that face for strength.
I cut a dog shape out of black paper and stuck it to the front face for fun. And I added an “armed” indicator LED to its nose while I was at it. This LED is directly connected to the 5v and GND pins of the Arduino through a series 470 ohm resistor.
Once done, I stuck the whole thing to the front door using double-sided foam tape. Our door is just wood without any paint on it, so the tape isn’t a concern. If you don’t want to use tape, you can use small suction pads/cups instead. But make sure to not have too much gap between the door and the RADAR sensor. I made sure it sat flush and tight against the door.
Step 12: Final Tests
Now, before you leave the house, power ON the device and you should be fine. But there is one big problem with BARK 1.0. It starts barking on me too. I don’t want Bark to bark at me when I’m at the door. And that is the reason I used an ESP8266 instead of an Arduino. It can connect to the internet! My plan for Bark 2.0 is to add an IOT feature, where it is connected to my phone through the internet. When Bark will detect that I am within the location of my house, it will not bark. Another advantage of connecting it to my phone is I can set it to send me a notification every time it barks. This way I will know somebody is at the door when I am away. If you have more ideas for version 2, feel free to leave a comment. Thanks for reading this far!