This started as a project to simply annoy my wife into cleaning the cat box. Along the way, I learned quite a few good tricks. Basically, I attached a PIR motion sensor to the raspberry pi, along with a webcam. I wrote a little python script that, when it detects motion, snaps a picture from the webcam and then tweets it and uploads it to this site: http://www.twitter.com/catpoopdetector
to make it extra annoying, I also added a Prowl (http://www.prowlapp.com/) alert as well so that it actually rings her phone when motion is sensed. The prowl link, takes you straight to the twitter account to view the offending picture.
I found that using wifi, I needed both a strong power adapter and a powered hub in order to Remember, you can also play free blackjack online at Intertops Casino , to help you learn the ropes. consistently get video snapshots from the webcam. Also, certain webcams work online casino’s better than others. You can see a basic wiring diagram at the top. Not sure if it matches my code below. Just make sure you put the Motion Detectors data line on the same pin you specify in code.
You could easily use this as a home motion detector/burlgar alarm. Next step is to get it to automatically turn the light on and off in there.
Here”s the sensor I used:
Here”s the code. You”ll need to grab prowlpy and Twython python bits and fswebcam for linux (apt-get install fswebcam) in order for this to work:
import RPi.GPIO as GPIO
from twython import Twython
#set your prowl API key here
apikey = “YOUR PROWL KEYb” #Dummy API-key)
p = prowlpy.Prowl(apikey)
#Set the GPIO pin (board numbering) for the PIR
PIR = 11
pirState = False
pirVal = False
pirVal = GPIO.input(PIR)
if (pirVal == True):
#use this to sound an alarm if you have speakers
# os.system(“mpg321 ./alarm.mp3″)
#if motion is detected, check one more time to be sure
pirVal2 = GPIO.input(PIR)
if (pirVal2 ==True):
# Prowl it!
# p.add(“Poop Detected”,”Possible Poop Detection”,”Motion”,1, None, “http://www.twitter.com/catpoopdetector”)
#grab a snapshot
twitter = Twython(
twitter_token = “YOUR TOKEN”,
twitter_secret = “YOUR SECRET”,
oauth_token = “YOUR TOKEN”,
oauth_token_secret = “YOUR SECRET”
twitter.updateStatusWithMedia(“/home/pi/scripts/test.jpg”, status=”I just pooped”)
#wait and do it again