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!
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).
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.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
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
- Wire the MCP3008 according to the wiring diagram
- Enable SPI on the RPi.
- This is a great tutorial on how to do that. Start on step 2 in the tutorial here: https://www.instructables.com/id/Wiring-up-a-MCP300...
Step 3: Software
- This code is adapted from http://www.linuxuser.co.uk/news/10-raspberry-pi-up...
- Make the python script by typing into the terminal:
cd ~ mkdir Pupnet cd Pupnet/ nano pupNetDriver.py
- To find out what format to use for the text via email follow this guideline (taken from https://www.raspberrypi.org/forums/viewtopic.php?f...):
- Sprint firstname.lastname@example.org
- Verizon email@example.com
- T-Mobile firstname.lastname@example.org
- AT&T email@example.com
- AIM +1phonenumber
- Then copy and paste the following code (or copy it from here https://raw.githubusercontent.com/thepinkturtle/Pu...) into the pupNetDriver.py file you just created.
- In order to exit and save nano type
- ctrl + x
#!/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 & 3) << 8 ) + r # 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