Introduction: Dog Bark Sensor

I recently got a new puppy and I wanted to know if he was barking when I left the house. I rigged this little hack together to send me a text message if he barks.

This is my first instructable so I'd like to apologize for any errors. If you could point them out in the comments I'll do my best to correct them. Thanks!

You'll need:

1) Raspberry Pi 2 I'm running it on Raspbian Jessie (I bet it will work on other models and OSs but I haven't tested it).

2) Breadboard.

3) MCP3008 ADC https://www.adafruit.com/products/856.

4) Electret Microphone Amplifier - MAX4466 with Adjustable Gain https://www.adafruit.com/products/1063 (however, you won't use the adjustable gain).

5) A way to connect the Raspberry Pi to the network (I used an ethernet cable).

6) ~12 wires for the breadboard and GPIO pins.

Step 1: Update

You'll need to update your Raspberry Pi (RPi). Type into the terminal:

sudo apt-get update
sudo apt-get upgrade

Step 2: Wire MCP3008 and Enable SPI

Step 3: Software

cd ~
mkdir Pupnet
cd Pupnet/
nano pupNetDriver.py
    • Sprint phonenumber@messaging.sprintpcs.com
    • Verizon phonenumber@vtext.com
    • T-Mobile phonenumber@tmomail.net
    • AT&T phonenumber@txt.att.net
    • AIM +1phonenumber
#!/usr/bin/python
# python program to communicate with an MCP3008
# Import our SpiDe wrapper and out sleep function
import spidev
import os
# Establish SPI device on Bus 0, Device 0
spi = spidev.SpiDev()
spi.open(0,0)
def getAdc (channel):
	#check for valid channel
	if ( (channel > 7) or (channel < 0) ):
		return -1
	
	# Preform SPI transaction and store returned bits in 'r'
	r = spi.xfer( [1, (8 + channel) << 4, 0] )
# Filter data bits from returned bits
	adcOut = ( (r[1] & 3) << 8 ) + r[2]
	
	# If adcOut is greater than 700 send a text via email through terminal
	if (adcOut > 700 ):
		os.system("echo 'WOOF! WOOF!' | mail your_phone_number@your_carrier_format.com")
		
while True:
	getAdc(0)

Step 4: Set Up SMTP

The last step is to setup SMTP.

Follow the simple tutorial from here http://www.raspberry-projects.com/pi/software_util...

To start up the service type into the terminal:

cd ~
cd Pupnet/
cd sudo python pupNetDriver.py

You should have a working bark sensor now. If you need to adjust the sound level higher or lower play with the if statement in the code. If the number is higher than 700 the sound to set it off will need to be louder. If its lower than 700 the sound won't need to be so loud. Let me know if you have problems in the comments below.

if (adcOut > 700 ): ...

Step 5: Sources