The sys admin's daily grind: Charly's doorbell Pi
Ring, Ring
When Charly puts on his headphones at home, he often fails to hear the doorbell. So, he dreamed up a solution with a Raspberry Pi Zero, a noise detector, and a power outlet with a LAN connection.
Sometimes I sit in my home office using a headset, listening to some good old electric guitar music or taking part in a teleconference – which is naturally slightly less invigorating. As a consequence of my acoustic escapism, I tend not to hear anyone who rings the doorbell.
To restore my social presence, I opted for the smallest version of the Raspberry Pi, the Zero. The Pi needs to detect the bell circuit closing and output a visual alert. In Germany, doorbells use 8 to 12V alternating current. You could convert this to DC and tune it down to a Pi-compatible voltage, but this would involve a mess of wire in the doorbell housing.
So, I went for a noise sensor. These things are very simply made, need a supply voltage of 5V, and send a signal via the output pin when they pick up a noise [1]. A blue rotary potentiometer lets me set the noise level. The sensor and the Raspberry Pi both fit into the doorbell housing (Figure 1).

Because of its proximity to the acoustic event, I can set the sensor's switching threshold to a fairly high level – it will not be tripped by the kids shouting or the dog going mad in the hallway.
Lights and Tweets
The small Python program from Listing 1 evaluates the signal in an infinite loop. The GPIO Zero library [2], which I used here, might not support noise sensors, but its Button()
function is all I need to evaluate the sensor's short voltage pulse. Luckily, it includes a debounce feature: bounce_time=2
summarizes all the signals the Raspberry detects within two seconds.
Listing 1
Doorbell Script
01 #!/usr/bin/env python3 02 from gpiozero import Button 03 from signal import pause 04 import os 05 06 def bell_rang (): 07 os.system("/usr/local/shellscripts/bell.sh") 08 09 button = Button(21, bounce_time=2) 10 button.when_pressed = bell_rang 11 pause()
When the delivery man rings the bell now, the script bell.sh
launches, which actuates a power outlet connected to my LAN, which switches on a lamp in my office. At the same time, the script sends a tweet on Twitter. I know you can buy wireless doorbells down at the hardware store, but the doorbell Pi is more my style.
Charly Kühnast
Charly Kühnast is a Unix operating system administrator at the Data Center in Moers, Germany. His tasks include firewall and DMZ security and availability. He divides his leisure time into hot, wet, and eastern sectors, where he enjoys cooking, freshwater aquariums, and learning Japanese, respectively.
Infos
- Source for noise sensor: http://www.amazon.de/gp/product/B00N1TSM7K
- GPIO Zero: http://gpiozero.readthedocs.org
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.
News
-
Arch Linux 2023.12.01 Released with a Much-Improved Installer
If you've ever wanted to install Arch Linux, now is your time. With the latest release, the archinstall script vastly simplifies the process.
-
Zorin OS 17 Beta Available for Testing
The upcoming version of Zorin OS includes plenty of improvements to take your PC to a whole new level of user-friendliness.
-
Red Hat Migrates RHEL from Xorg to Wayland
If you've been wondering when Xorg will finally be a thing of the past, wonder no more, as Red Hat has made it clear.
-
PipeWire 1.0 Officially Released
PipeWire was created to take the place of the oft-troubled PulseAudio and has finally reached the 1.0 status as a major update with plenty of improvements and the usual bug fixes.
-
Rocky Linux 9.3 Available for Download
The latest version of the RHEL alternative is now available and brings back cloud and container images for ppc64le along with plenty of new features and fixes.
-
Ubuntu Budgie Shifts How to Tackle Wayland
Ubuntu Budgie has yet to make the switch to Wayland but with a change in approaches, they're finally on track to making it happen.
-
TUXEDO's New Ultraportable Linux Workstation Released
The TUXEDO Pulse 14 blends portability with power, thanks to the AMD Ryzen 7 7840HS CPU.
-
AlmaLinux Will No Longer Be "Just Another RHEL Clone"
With the release of AlmaLinux 9.3, the distribution will be built entirely from upstream sources.
-
elementary OS 8 Has a Big Surprise in Store
When elementary OS 8 finally arrives, it will not only be based on Ubuntu 24.04 but it will also default to Wayland for better performance and security.
-
OpenELA Releases Enterprise Linux Source Code
With Red Hat restricting the source for RHEL, it was only a matter of time before those who depended on that source struck out on their own.