Hacking a doorbell (adding WiFi)
I've been on another Home Assistant tangent over the Christmas holidays - mynow run ESPHome, which makes it easier to integrate with Home Assistant, rather than the Grafana API (although the graphing isn't very good), and I decided I want a doorbell.
Off-the-shelf "smart" doorbells are quite expensive and always seem to rely on cloud services, and I do not want to intimidate a postal worker with a camera. Instead, I purchased one of the cheapest wireless doorbells off Amazon. It wasn't the cheapest, because I went for one which had a self powered button. This is quite cool actually - the power to transmit the button beacon is generated by the act of pressing the button. No batteries to replace! I was fairly confident that it wouldn't be too hard to modify, or integrate with Home Assistant some how. I had two ideas for this:
- Add an ESP8266 or ESP32 microcontroller to the mains powered doorbell receiver somehow.
- Monitor the 433MHz band for signals and try and use this to trigger Home Assistant some how.
The second seemed like more of a backup plan, even if I do like messing about with radios. I don't have an SDR setup on the machine running Home Assistant and it seemed like a lot of effort to add this, even if there is a plugin called
rtl_433 which makes it easier to add support for 433MHz devices using an RTL-SDR. So, attempting to do the first, my process relatively methodical (I think). First, identify a stable DC voltage within the receiver, and second, find a signal which changed state when the doorbell button was pressed.
Stepping through the power supply, I was able to identify a stable DC 4 volts across the filter capacitor. The ESP8266 needs 3.3v, but I have some small 3.3v regulator modules which are ideal for this. These are incredibly cheap and handy to buy in bulk, costing only 50p each or so on eBay when imported from China. I was not too concerned about the power consumption or overloading the supply. The speaker will draw quite a large amount of current and I was planning to set this to the lowest volume. Now that I had power sorted, I prepared an ESP8266 by flashing a basic ESPHome binary, which would then allow me to do over-the-air (OTA) updates from ESPHome.
Identifying a signal which changed when the doorbell button was pressed was a little more difficult, but not too bad. I was hoping I would be able to find datasheets online for the chips inside the receiver, but none of my searches revealed anything. Instead, I went between ground and each pin of the chips looking for something which was reading 0v. I then pressed the doorbell button to see if it changed. It only took me a few pins to find this fortunately! The voltage of this when high was also 4v, which is too much for the ESP. I set up a simple voltage divider using a 10k and 20k resistor which gives me something close enough to 3.3v - probably something like 2.7v but the voltage was actually a tiny bit over 4v anyway. From the potential divider I passed this into GPIO3 and added a simple binary sensor to the ESPHome config. After flashing, everything was working nicely!
- platform: gpio
The sensor shows up nicely in Home Assistant. I've added an automation on this to send notifications to my phone and laptop. My MagTags have a service defined, thanks to ESPHome, which allows me to ring a chime on the built in speaker. So I have notifications everywhere! I'm never going to miss the door again.
While I'm posting, I might as well show the CO2 sensor I added to one of my MagTags. This is what happens when you don't have any of those fancy AdaFruit interconnect cables! CO2 tracking is slightly alarming. I'm struggling to understand how it is so difficult to keep it under 700ppm, and how it goes up so quickly!