IoT Doorbell Part 2 (Feather HUZZAH / ESP8266)

Previously I discussed my intentions to smart-ify my doorbell – I want to know if I’ve missed a delivery while I’m out, and this seemed like a good way to go about it.

I already opened up the doorbell receiver last time – now let’s take a look inside.

doorbellInside1

Hmm, the electronics are large enough that we should be able to play around with them – I was worried the PCB would be covered in tiny SMD components, but it seems like that’s not the case – excellent!

I’m interested in two things at this point – a way to power a small micro-controller / WiFi module (3.3-5V) and some sort of signal that I can read to check if the doorbell is currently ringing.

I want to give an ESP8266 module a try for this – I’ve played around with XBEE modules quite a bit before, but getting a setup that will connect using WiFi sounds appealing, and I’ve been looking forward to trying the ESP8266 out.

Adafruit recently released their Feather HUZZAH boards which use the ESP8266 and add a voltage regulator (5V->3.3V), battery charging, USB comms and a bread-boardable layout – so I thought I’d give one of these a try.

featherHuzzah

To run the Feather HUZZAH, I’ll need 3.3-5V power with at least 150-200mA headroom, and I’ll need a 3.3V compatible logic signal to indicate if the doorbell is ringing.

Let’s take a closer look at the PCB:

DoorbellInside2

Jackpot – it looks like there are connections for an expansion module on the left – VSS, VDD and LED – probably so the PCB can be used in a more full-featured doorbell receiver.

The LED output sounds particularly interesting – perhaps it’s to add on an LED that lights up when the doorbell is ringing?

VDD and VSS should be positive and ground, hopefully VDD is a voltage I can use. I checked with a multimeter – 12V. Well, that’s not within the 3.3-5V range I was hoping for. Maybe I’ll still have luck with the LED output?

I grabbed the doorbell transmitter, pressed the multimeter probes against VSS and LED, and rang the doorbell. The sound chimed, and a moment later I saw the multimeter register 12V – victory!

So there’s 12V power and a 12V signal to indicate that the doorbell is ringing – we can work with that. A simple voltage divider from a couple of resistors should get the signal down to where we need it, but for the power we’ll probably need a voltage regulator.

First things first – 12V signal to 3.3V IO. Simple resistor divider should do it, let’s figure out the values. SparkFun have a great tutorial on voltage dividers here, it’s well worth a read if you’re forgetful like I am.

R1 will go from our 12V signal to the IO pin, and R2 will go from the IO pin to ground. Vin is 12V, and Vout should be as close to 3.3V (but under) as possible.

We can re-arrange the above equation to solve for the numbers we want, but honestly it’s probably quicker to bring up a voltage divider calculator – here’s one here.

We have two unknowns – the two resistors – so let’s pick one so we can calculate the other. 100K for R1 sounds like a good starting point. Solving for R2, we get a value of 37.9K – that doesn’t sound like a very common value, but 33K is pretty common – recalculating at 33K gives us a voltage output of 2.9-3.0V, which sounds good enough. Let’s go with 100K and 33K, two common resistor values.

That’s signal sorted. For power, I had a spare Pololu buck-regulator on hand (D24V22F5) which will regulate down to 5V at up to 2.5A – plenty of headroom there, but to be honest I suspect we’ll run into problems with the power supply circuitry on the doorbell’s PCB before the regulator runs into any trouble.

I soldered in the regulator and R1:

2015-12-31 00.39.24

I plugged the doorbell back in and quickly measured the output of the voltage regulator – a steady 5V, good so far but no load yet, so who can say.

I soldered R2 directly on to the Feather HUZZAH board, from the IO pin to ground. Next I soldered R1 into the IO pin, and the output from the voltage regulator into the 5V input on the board. At this point, I gave it a quick test to see if things worked – no LEDs on the Feather board, so it wasn’t looking good so far. I pressed the doorbell button to make sure I hadn’t broken it – no noise, not good.

Moving the doorbell button closer and closer to the receiver, eventually the receiver was actuated and started ringing – but at only 50cm range, this wasn’t really a viable solution for a doorbell. I measured the voltage across Vdd and Vss in this configuration – it had dropped down to nearly 5V – so it looks like the 12V used inside the doorbell is unregulated, and relies on a relatively constant and well-known load to stay at that voltage. This meant I wasn’t going to be able to get away with running anything off of the receiver’s internal power – curses.

The backup plan, then, was to power the ESP8266 externally. USB wall plugs are cheap, and I should be able to find something fairly inconspicuous, so I decided to wire a USB cable to the Feather HUZZAH board and leave the plug of the cable on the outside of the doorbell receiver.

2016-01-06 17.58.18

The resistors were soldered in dead-bug style between the relevant points. I enclosed them in heat-shrink first, to minimise the chance of anything accidentally shorting out. Once I was able to figure out where everything would fit into place, I also put a length of heat-shrink around the Feather board to protect it too.

2016-01-06 18.38.40
The Feather board fits snugly between the bolt post and the mains-related component it probably shouldn’t be touching. Seems safe!

Before closing it up, I needed to upload the code to the board – but I hadn’t written the sketch to actually monitor the doorbell yet. Luckily, the clever folks working on the Arduino-implementation for the ESP8266 have got code working for over-the-air (OTA) sketch uploading – all I needed to do was upload this example (with my network SSID / password added in) and I was good to go.

I did a quick test to make sure I could upload OTA before packing the doorbell back up – this stuff works! OTA updating is something I’ve really been interested in seeing working for a long time, and I’m really impressed people were able to get it figured out. I spent a while trying to figure out an implementation when I was playing around with XBEE modules on regular AVR based Arduinos, and I couldn’t find a way to do what I wanted – it’s crazy how quickly this stuff has been solved, and how well it works!

After confirming that I’d still be able to update the Arduino remotely, I put the doorbell back together. I wrapped a lot of tape around the USB cable, both to provide a little strain-relief (not too important here) and to make sure it was definitely protected from the mains wiring / prongs that it runs past (pretty important). A rubber-band to hold the two halves of the receiver together, and I was ready to plug it in.

2016-01-06 21.44.24
Don’t laugh.

I’ll be honest, having to power it externally kind of ruined the clean / magical feel I was hoping for. It’s pretty clear this doorbell has seen some surgery.

Nevertheless, a quick press of the doorbell button – and it works! The doorbell rings as it always did, so I’ve not broken anything – success!

The next step was to figure out how I’d remotely monitor the status of the doorbell, and what I’d do with that information (with great power, etc…). For that, you’ll have to wait for next time!

Riveting, I know.

Leave a Reply

Your email address will not be published. Required fields are marked *