Introduction: Super-cheap Wireless Doorbell
Like most dog owners, we love our dog. Our dog, Ada, has one trait that drives us nuts, though. When the doorbell rings, or somebody knocks on the door, she loses her mind, and for a 13 pound rat terrier/chihuahua mix, she has a very loud, air raid siren bark. On Halloween particularly, the barking is hard to take. This motivated me to come up with a wireless doorbell that would send me an iPhone notification when somebody was approaching the door, so I’d know before Ada did.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: What You Need
- A wireless ‘driveway motion sensor’ that includes flashing lights as part of its notification. I used this, which at the time was on sale for $10 but you can use something similar: Wireless Driveway Alert System
- A photocell
- A 10K resistor
- A breadboard
- Jumper wires
- 2 Alligator Clips
- Electrical tape
- A Beagle Bone Black
- an iPhone
- the 'Prowl' App http://www.prowlapp.com/
Step 2: Preparing the Beagle Bone Black and Your IPhone
I installed ubuntu on my Beagle Bone Black. Likely, you can do this w/ the ‘out of the box’ Angstrom distribution. But if you want to be like me, install Ubuntu.
Note that while I installed 13.10, you likely will want the more recent version, whatever it is when you are reading this (hello, people of the future! Sorry we left a mess for you!). This is a good resource: http://elinux.org/BeagleBoardUbuntu#eMMC:_BeagleBo...
Download the Ubuntu 13.10 image http://s3.armhf.com/debian/saucy/bone/ubuntu-sauc...
Uncompress file using Unarchiver on Mac OS X, 7-Zip on Windows or xz on Linux.
Copy the image file to the SD card using dd on Mac OS X or Linux or an image writing program on Windows.
See this page for more info on how to do this: http://s3.armhf.com/debian/saucy/bone/ubuntu-sauc...
I then did the usual Python stuff:
sudo apt-get install python-setuptools
sudo apt-get install build-essential python-dev python-pip -y
sudo apt-get install git
sudo pip install distribute
sudo pip install --upgrade distribute
sudo pip install Adafruit_BBIO
You can also refer to the adafruit tutorial, there are some good ones for the Beagle Bone Black there: http://learn.adafruit.com/setting-up-io-python-li...
If you are using an iPhone, install the Prowl App and set up a Prowl account: http://www.prowlapp.com/
You will need to install the prowlpy library for Python:
git clone https://github.com/jacobb/prowlpy.git
sudo python setup.py install
You can find the Prowl API which you will need to add to the Python code that will run on the Beagle Bone Black here: https://www.prowlapp.com/api_settings.php
Step 3: Preparing the Motion Sensor
This part’s easy because I did it in the least intrusive way possible. You don’t even need to open the case unless you want to disable that annoying alarm (as the whole point of this exercise is avoiding annoying sounds, I did).
To do that, open the case (partially) and look for the piezo buzzer which is the ‘speaker’. Cut one of the wires. For this model, the wires are yellow. I say open the case partially because I had the sense I could not fully open it without breaking it.
To attach the photocell, use the ever popular electrical tape to tape it over the lights (and prevent interference from ambient light). I left one of the lights uncovered for debugging purposes.
Attach alligator clips to each of the leads.
Wow. That's so easy, it hardly qualifies as hardware hacking. You better check out some more complicated Instructables after this one, to get back on track.
Step 4: Wiring It Up
We are using the ADC inputs on the Beagle Bone Black. These are part of the reason I like the Beagle Bone Black better than the Raspberry Pi. The RasPi has no built in ADCs, so you have to use an external one. The BBB also has a lot more GPIO pins. I do not want to get into a big RasPi/BBB shootout, though. I have a couple RasPis and they’re fine for what they do (MAME, and running the RFID access system and networked thermometer interface at Bloomington, IN’s hackerspace, Bloominglabs). All I’m saying here is, give the BBB a chance, you may like it, and it’s always good to broaden your horizons.
The Fritizing diagram illustrates how this is done (again - easy!).
Step 5: The Code
Here’s the code I used (also attached):
import Adafruit_BBIO.ADC as ADC
API_KEY = '<whatever yours is>'
sensor_pin = 'P9_39' # AIN0
reading_threshold = 0.2
wait_before_notify = 10 # only notify once in this many seconds
last_notify = datetime.datetime.min
if __name__ == "__main__":
p = prowlpy.Prowl(API_KEY)
reading = ADC.read(sensor_pin)
print('%f\n' % (reading))
if reading < reading_threshold and (datetime.datetime.now() - last_notify).seconds > wait_before_notify: print "stuff done happened"
p.add('Door','Visitor',"You have a visitor", 1, None, None)
last_notify = datetime.datetime.now()
Hardly any code at all. Isn’t Python great?
You will need to add your own Prowl API key as discussed earlier. You will also in all likelihood need to workout what your threshold value is, because you may have a different photocell than I used. Well, good news everyone, this is easy to do.
Run the Python code for a bit and watch the readings. Then trigger the motion sensor and see how low the readings go when the light flashes. There should be quite a big gap in the values. Pick something in the middle and use that as the ‘reading_threshold’ value.
Step 6: Setting It Up
Actually, this was the most time consuming part for me. You need to set it up so you get notified when people are at your door, but don’t get false positives from people walking by your house.
I also wanted to get a bit of advance notice before our visitor would have a chance to knock or press the doorbell. I ended up with it facing the driveway at an angle, with the classy cardboard to focus it somewhat. That cardboard is very raggedy. That's because this has been in place and running for over a year now! Worth noting: I haven't yet had to change the battery. It's inspired me to put effort into learning more about and using better power management techniques in my own projects.
I do get the occasional false positive, like when my daughter dances around in front of it to send me notifications.
Step 7: Running It
I tend to just run it like this:
nohup sudo python prowl_doorbell.py &
You can set it up to run when your BBB is booted up if you want.
Step 8: Conclusions
This works really well, except for the time it fell off its mount. To its credit, the motion detector still worked fine after a 3 foot drop onto concrete, but don’t test this out. Also, as I mentioned, it's been running over a year on the same battery. Overall, the limiting factor in its reliability is the reliability of our Internet Service 'Provider', whose name rhymes with bombast.
This is an example of how simple it can be to add some wireless sensors to your household. Dedicating a Beagle Bone Black to this seems like a waste, but this can be only one of many sensors running on your Beagle Bone Black, as it is for me. I also run a little web server on mine.
Did this solve the problem with Ada losing her mind when people come to our door? Sort of. For a while. In Pavlovian fashion Ada eventually figured out the buzzing of my phone or the notification sound meant somebody was at the door. And eventually, she realized when we called in to order food, it meant somebody would be coming to our door soon, putting her in hypervigilant mode and triggering some false positives from her.
Occasionally though, she's distracted by something, and I can beat her to the door.
Still, we love Ada a bunch. How could we not? As far as she knows, protecting us like this is her job, and she takes our safety very seriously. ADT has nothing on ADA.