So, we recently fixed our front gate that had been getting steadily worse since we moved in. Better late than never, I always say. Installing the gate made it clear of two things: one, that the doorbell buttons in front of our door (which still don’t work) were made even more useless by a locking gate and two, that the SkyBell 2.0 doorbell I bought to replace them won’t work unless I mount it on the outside of the gate.
And that’s how the Raspberry Pi + SkyBell project was born!
However, being that I’m mainly a software developer nerd and not (yet, anyway) an electronics nerd, there were some problems up front. While I have had some fun piecing together sensors and LEDs on an Arduino board in the past, I never got around to building anything I’d actually plan to use on a regular basis. I mean, I built a presence detector with a co-worker at Oakley so we would both know when people entered or exited our four-man bullpen, but that was as crazy as things got.
Needless to say, I’ve had to do a bunch of research for this project. For starters, I don’t have the existing low voltage doorbell wiring typically required to install the SkyBell. Luckily, they have some instructions on using a 12-volt DC adapter in part of their instruction booklet. All it requires is a 10-ohm/10-watt resistor one one of the wires connecting up to the unit.
The only problem at that point was how to detect that the door bell button was pressed on the SkyBell! I knew logically it had to work with a traditional doorbell system, and once I learned how that worked (a simple closed circuit causing an electromagnetic piston/hammer to hit actual chimes), I figured I just had to test the unit to see if there was a voltage change. After copious amounts of reading, searching and reaching out to my high school friend, (who is an electronics whiz), it became clear I’d have to prototype it and measure with my voltage meter (I absolutely recommend one of these if you’re green when it comes to electronics).
So the next step was ordering up the parts for the prototype I could measure. For that, I ordered the 12 volt DC adapter ($7.99) and 10-ohm/10-watt resistor ($5.82 for 10) (both pictured left) from Amazon. It arrived just yesterday, so I immediately cut the end off of the DC adapter, split the cable a bit, spliced one lead onto the resistor, then spliced the two leads coming out of the back of the doorbell — one onto the exposed adapter wire and the other onto the other end of the resistor. Of course, I had to expose a bit of the wire before I could measure anything, but once I’d done that, I was ready to get testing.
As you can see here, I did just that (albeit with a very clumsy approach of holding everything all at once while trying to record using my phone):
In the end, I got a clean reading. Admittedly, I don’t know if 200 is the right setting to use on the voltage meter, but it got me the results I was after. There is a dramatic decrease in voltage for roughly eight (8) seconds on push of the doorbell button.
Result for phase one of the Raspberry Pi + SkyBell (PiBell): SUCCESS!
What this means in terms of the project overall is that I should be able to detect the change in voltage once my Raspberry Pi 3 gets delivered. However, from my various learnings, it’s clear it would not be wise to hook 12 volts directly to my Pi; it would break (plus it would smell terrible).
This brings us to our next question and the next thing I’ll be testing, which is: how do you detect a change in 12 volts using the Raspberry Pi (which lacks analog-to-digital converters — ADCs — that Arduino has) without frying the thing? Well, that’s where optocouplers come in.
So, as I understand it, the basic idea behind an opto coupler is this: rather than connecting things directly, you power a tiny LED inside a housing with the higher voltage line and THAT will send light over to a photocell (a resistor that changes resistance based on how much light it’s exposed to), which is actually hooked up to one of the GPIO pins on the Pi. This way, there is physical separation from higher/dangerous voltage, so any spikes will not harm the device on the side of the photocell (again, the Pi).
As you can see in the above diagram, I’ve had a confusing time learning about what each symbol means on a circuit diagram. Or what the right resistance is to use in some places. For example, after some asking around, it was made clear that a 10k resistor between the 12-volt DC power and pin 1 on the optocoupler is necessary to avoid frying the LED inside. The rest of the placements for pin connections (four actual connections in total) actually makes sense, which is what will lead me to phase two of the project: hooking up the optocoupler to the Raspberry Pi, then feeding a wire connection off of the existing doorbell wire to detect button pushes!
For that, I’ve ordered the CanaKit Raspberry Pi 3 Ultimate Starter Kit ($89.99), which comes with a bunch of cool stuff (including the resistors I need!). Plus, I ordered 40 feet of outdoor rated cable ($13.49) to connect to the actual 120V output, and the PC817 Optocouplers ($6.99 for 10). I went with the PC817 optocoupler over the 4N35 because, as far as I can tell, it does the same thing but only has four pins to worry about (trying to keep confusion to a minimum here).
Overall, I still need to prototype the entire setup, make sure nothing sizzles, figure out how to detect the voltage change from the Pi from, say, Python, and then from there, do whatever I want. I’m thinking I’ll play a sound over SONOS for starters.