Hacking the doorbell

I bought a new doorbell. It actually came as a set, with two ringers. One is battery operated and the other is mains powered, plugging straight into the wall. I once again find myself attempting to keep up with Nick. Having seen his doorbell project I knew exactly what I had to do: it was time to hook my doorbell up to an Arduino board and put it on the internet.


The red wire is +3V, the black is ground. The doorbell chime unit used to draw its power from two AA batteries, so now it gets the same three volts from the Arduino instead.

The short dangling white wire is actually the antenna for wireless reception of the signal from the remote button, while the long white wire once completed the circuit to the buzzer. The Arduino treats it as an analog signal (and uses the built in pullup resistors to ‘steer’ the input to high). I should probably use it to drive a transistor to close a digital switch instead. This way works for now though.

The USB cable currently supplies the power and also acts as a serial line, down which the message that the doorbell has been triggered is sent. Eventually I’d like to use an ethernet shield, or even an ethernet-enabled Arduino like this one (which I do hope will be available soon!).

Here’s the Arduino sketch (tweaked slightly from Nick’s blog post).

int ledPin = 13;   // LED connected to digital pin 13
int potPin = 0;    // white doorbell wire to analog pin 0
int val = 0;

long time = 0;
long debounce = 5000;

void setup() {
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  Serial.begin(9600);           // open serial port at 9600 baud
  digitalWrite(14 + potPin, HIGH); // set pullup on the analog pin
                                // (analog 0 = digital 14, a1 = d15, etc)

void loop() {
  val = analogRead(potPin);
  if (val < 100) {              // if the circuit is completed
  // (for me, it generally drops from 1023 to ~ 15 when 'ringing')
    if (millis()-time > debounce) {
      digitalWrite(ledPin, HIGH);   // sets the LED on
      delay(500);                   // ...wait for half a second
      digitalWrite(ledPin, LOW);    // and turns the LED off
      time = millis();

To hook it up to my house’s twitter feed, I just need to open the serial line on the attached computer, doing something like this every time a new line is added

curl -u email@example.com:password -d status="There's somebody at the door" http://twitter.com/statuses/update.xml

Update: it’s now housed in an Altoids tin.

22 replies on “Hacking the doorbell”

  1. I have a very similar wireless doorbell, but obviously without this extreme modding. Sometimes my doorbell chimes when there’s no one there. It is very scary. Just thought I’d warn you.

  2. You should fix up a simple webcam to it, so that it takes a snap of your visitor and posts it to a flickr stream. Kind of a ‘Who’s at Roo’s?’.

  3. That would be fun. I’m also thinking it would be helpful to know when ‘attempted deliveries’ were no such thing. I’m convinced I frequently get a “sorry we missed you” slip through the door when the delivery person has neither rung the doorbell nor knocked on the door. It might be a bit geeky to use my timestamped database of doorbell events as evidence when complaining though.

  4. “neither rung the doorbell nor knocked on the door.”

    That has got me thinking… we need a vibration sensor for the cases where the visitor doesn’t ring the bell but knocks instead. Could also be used to spot things being posted through the letterbox.

  5. Yes.. as I typed it I was thinking of piezo elements. I wonder if I could mount something in the wooden panel next to the door, and still pick up enough vibrations when the door is knocked…

  6. It seems that you might be able to get away with some sort of sound detector or something.. you would have most of the same problems with the analog nature of sound versus the analog nature of a vibrations. By that I mean to say that “when is a knock not really a knock?” (via sound.) But you would have to solve that question using vibrations, also, no?

  7. It needs a converted cellphone with camera , so I can answer the door where ever I am, then a SMS operated door opener I can always be in for the parcels guy :-)

  8. The hidden scales sound like fun. Combine it with a rangefinder and you could offer visitors a meal based on their Body Mass Index.

    I was actually looking at SMS operated door locks the other day, thinking that it would be handy to be able to go out without having to take keys. (Especially as I’m better at remembering my phone than my keys). My wife wasn’t convinced. In fact, she said “I’m not paying 10p every time I want to open the front door”.

  9. How about taking a webcam apart, and mounting the lens inside your peephole? Then, when the doorbell is rung, you can be emailed, or even MMS’d an image of the person at the door…

  10. Let me compare that to my setup :-)
    When someone rings the doorbell and i’m not at home a popup on my PC opens and shows the person at the door (when the PC is online). Otherwise I get an email with the photos. The doorcom calls my mobile phone and I can talk to that person. Of course I can open the door remotely… Or the garage when a mailmal wants to leave a parcel…

  11. I’ve been reading all this stuff, and I have to say it – hand on heart. You people really should get out more.

  12. Hi there – I stumbled across this article and became very excited… exactly what I’ve been looking for.

    I’m still trying to figure out how the code “sketches” work… but have a solid background in C/C++, C#, Java, so should be no problem.

    However, when the device receives the serial data from the push button, how are you calling your other script that sends the e-mail? It’s this command:

    “curl -u email@example.com:password -d status=”There’s somebody at the door” http://twitter.com/statuses/update.xml

    Where is the file “curl” located and how do you call that from the code on your controller device?


  13. curl is a tool for talking to web servers. In this case (via the -d option) it’s being used to make an HTTP POST. The computer I was using as a bridge from the Arduino to the web is a Mac, which has curl ready to go on the command line. If you’re using any sort of Linux, it should Just Work, otherwise you’ll want to find a copy of Curl or handle the HTTP POST in whatever way is most comfortable for you.

  14. So, do you have a separate app on your Mac that reads the serial data from the Arduino when the button is pressed?

    It doesn’t look like the Arduino language has much to it, unless you extend it with your own C/C++ code.

    My idea was to have some application on the PC listening to the Arduino COM port for any data that it sends, and then handle the “ring” accordingly. In my case, I don’t want to POST anything anywhere, just send an e-mail from the local machine.

  15. Yep, that’s right. The Arduino is good at interfacing with hardware, but when I want to use an input to do something webby I had to read the serial line and handle the event on a computer.

    A nice alternative, if you want to avoid having a computer running the whole time, might be to use an Ethernet shield which plugs into your Arduino like this one from Nuelectronics or this (announced but unreleased) one from Tinker.

    I have not played with an Arduino Ethernet shield yet. From what little I know about the Ethernet shields, I’d imagine that using one to send an email should be pretty straightforward. I’ve been jealously watching Nick’s experiences with a pre-release one from Tinker. He gave a great presentation at HomeCamp which is well worth watching.

Comments are closed.