We had a few cold days here. In those days I noticed that my doorbell was not working. Cold and batteries don’t go together well.
My doorbell previously failed because of a dead battery, or just because it’s a cheap crappy device. So I thought it was time for a better doorbell, preferably one that doesn’t need batteries.
I like the idea of having a smart doorbell so I can get a notification on my phone. But almost every smart doorbell out there has a camera and intercom function. I don’t need that. I just want to have notifications on my phone. But I still want to have a bell or speaker in my house.
So I googled a bit and found that there are no ready-made solutions that fit my needs at an affordable price. But there are some people who have made something themselves.
One solution I liked is https://frenck.dev/diy-smart-doorbell-for-just-2-dollar but it looks a little complicated to build. Another project I found was https://www.instructables.com/DIY-Smart-Home-Doorbell-for-Less-Than-40. This one involves a Raspberry Pi and uses smart lights and Telegram, it doesn’t have an external bell but it gives me a lot of inspiration to start with.
So I ordered a Raspberry Pi 3 Model A+, a 16GB SD Card to install the OS, and some jumper wires. As a power supply for the Raspberry I am using a micro-USB phone charger which I already had. Together with a new switch button and a few meters of cable I have spent around 50 euro’s (that’s like 60 dollars).
While waiting for the Raspberry to arrive I’m starting to read articles and watch YouTube video’s about the Raspberry and it’s capabilities. I saw that the Raspberry Pi can provide power trough the connection pins (GPIO) and I came up with the idea to modify the button of my wireless doorbell so it would always be in a pressed state and connect the battery connections to the Raspberry. Since the battery (CR2032) is a 3V piece, I was hoping that 3V3 wouldn’t be a problem either.
At this point my idea is complete. When someone presses the button this should happen:
- Activate my old wireless bell
- Blink my Philips Hue lights
- Send me a Telegram message
To make it possible to send Telegram messages I had to create a Telegram bot which is relative easy to do. I don’t think I need to explain the entire process but most of the information can be found at https://core.telegram.org/bots
Now the fun begins. I’ve created some code to test if I can control my lights and send me a Telegram message. It was amazing to see that it immediately worked and how easy this was.
When the Raspberry arrived I’ve transferred my code so I could test the GPIO connectors. My code defines the connectors for the button “Button(2)” and for the doorbell device “LED(22)”.
I wanted to start the Python script automatically when I boot the device. To do this I’ve added “sudo python /home/pi/Desktop/doorbell.py > /home/pi/Desktop/log.txt 2>&1” just before “exit 0” in etc/rc.local
So now after booting my Raspberry Pi it runs the Python script and also logs any data to a file at my desktop.
The function to ring my old bell is called before sending the other signals as it doesn’t require an internet connection and is theoretically the fastest.
With all the code in place, it’s time to connect everything and hope my old doorbell will work with a short pulse of 3.3V. I soldered the battery connectors to jumper wires and soldered a copper connection at the switch so that it will always be in a pressed-in state.
Now press the button and …. It works! Without any delay I hear my cheap crappy wireless doorbell making it’s sound and a second later I receive my DING DONG Telegram message while my lights also flashing green. I am really satisfied with how my doorbell works with the new smart features and without ever having to worry about the batteries.
The entire script can be found here. As I mentioned Python is not my primarily coding language so maybe it could be written better, but it does the job very well.