Introduction: Barking Dog Alarm

The instructable below describes how to create a barking dog alarm: when someone gets close to your house door, a barking dog sound will be triggered from inside the house making all undesirable guest go away.

For this set-up, you will need:

- One raspberry Pi, here I am using a raspberry pi 2 model B, but any model will do the job.

- One arduino nano, for controlling the ouside detector (got mine for less than 7 euros).

- One passive infrared sensor used as a motion detector (less than 2 euros)

- One RF 433MHz transmitter and receiver module. (got mine for less than 6 euros but seems that some cheaper ones are available)

- 9V battery ( 2 nos) and connectors

- One LED

- One Resistor (220 ohm)

I have used and modified some pieces of existing projects to create this one, so I will post my modified code as well as point to the original projects.

There are two different parts in this project:

1. The detection/transmitter part to be placed outside near the entrance door and that will send a RF signal when motion is detected.

2. The receiver part that will be placed inside the house and connected to an audio amplifier and to some speakers to trigger the barking dog sound when the RF signal is received.

Step 1: Setting Up the Transmitter (arduino Nano + PIR + RF Transmitter)

For the transmitter, you will need to set up the arduino nano to receive motion detection information from the PIR and transmit some data through the RF transmitter to inform the receiver device (raspberry pi).

The hardware setup for the receiver is identical to step 2 and step 3 of the followng instructable:

https://www.instructables.com/id/ARDUINO-WIRELESS-HOME-SECURITY-SYSTEM/step2/TRANSMITTER/

https://www.instructables.com/id/ARDUINO-WIRELESS-HOME-SECURITY-SYSTEM/step3/Connect-The-RF-Transmitter/

To sum up, you have to connect the

PIR Pin Arduino Pin
vcc -----> 5v

GND . ......> GND

Out ........> D2

You can also refer the fritzing schematic.

Concerning the code, it is using another library than the above instructable. Here we will be using RC Switch library, because this library does exist both for the arduino (here our sender) and for raspberry pi (here our receiver).

Download and install the following library.

https://code.google.com/p/rc-switch/

Then flash the arduino nano with the code from attached BarkingDog_Transmitter_code.txt

Step 2: Setting Up the Receiver (Raspberry Pi+ RF Receiver + Audio Amplifier + Speakers)

The receiver part consists of essentially the raspberry pi, the RF receiver and some speakers. To have a good sound quality you will need an audio amplifier as well.

Pre-requisite

- Raspbian - This part assumes that you have already set-up your raspberry pi with raspbian for instance.

- Wiring Pi- You will also need to have installed

wiringpi

Instructions on how to download ans install can be found here:

https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/

- mpc player/mpd daemon- in order to play the music you will need to install music player client and music player daemon, to do so:

nstall the mpd and mpc packages:
sudo apt-get install mpd mpc

change the permissions of mpd (just to make sure):

sudo service mpd stop

sudo chmod -R g+w /var/lib/mpd

sudo chmod -R g+w /var/run/mpd make a change to the mpd config file /etc/mpd.conf

sudo nano /etc/mpd.conf

To play local files make sure to have the following line uncommented:

bind_to_address “localhost”


- Barking dog mp3 download- You need to look on the internet for a barking dog mp3 sound and download it in the music player default library, in my caseI had to download it here: /var/lib/mpd/music/ (this can be retrieved from the variable music_directory in the file /etc/mpd.conf, in my case the file contains:

music_directory '/var/lib/mpd/music/'

Name the file Big-dog.mp3 or modify the file BarkingDog.cpp to adapt the file name of the mp3 to play.

- RC Switch - Then you need to install the RC switch library for Raspberry PI. I have copied it and added a program BarkingDog.cpp used to create the utility to sniff for the specific message sent from the arduino and trigger the launch of music afterwards.

you can download the code from here:

https://github.com/issamy/BarkingDog

Once downloaded, you can build the utility by opening a console to the folder and launching make.

To execute the utility launch it as follow:

sudo ./BarkingDog

- I have not tried this part but in order to autostart this program at boot, you can edit /etc/rc.local

sudo nano /etc/rc.local

and add the following line:

sudo /home/pi/BarkingDog/BarkingDog &

Step 3: Going Further

To go further on this project, you can add a batter to the transmitter and create a box for it, in order to hang outside your front door.

Note that you can have several tranmitter for each door.

The code might be optimized for power saving as well (example make the LED blink)

The transmition/reception range of the RF transmitter/receiver can be improved by adding an antenna.

you can refer to step 9 of another instructable to do so:

https://www.instructables.com/id/ARDUINO-WIRELESS-HOME-SECURITY-SYSTEM/

Please let me know if you have any suggestion to improve this post,

Regards