Making a doorbell semi-smart

Someone's ringing my bell

If you’re anything like me then you sometimes miss the doorbell ringing.

It may be because you’re engrossed in a movie and the doorbell sound doesn’t register. Or you might be (in these COVID times) in a make shift home-office with the door closed and an air-con blasting out. Or you may even be out of home.

Can we add some home-automation smarts to a dumb doorbell?

How does a doorbell work?

Your typical doorbell is powered by a transformer; maybe 16V AC. Yes, it’s an AC circuit. This causes many complications for smart devices, and even lighted doorbell switches (which need a diode to cause the light to work!)

Side note: A smart doorbell like a Ring needs to draw enough current to power the smart electronics, but not enough to cause the doorbell to actually ring. This is sometimes an art, given the sheer variety of doorbell chimes, so it’s not uncommon to hear complaints of “buzzing”.

This is my transformer:


But the doorbell circuit itself is pretty simple. It’s a a simple loop between the transformer and the chime with a button in the middle. When you press the button the circuit is complete and the chime rings!

One Button

Now a number of houses have two doorbells. They’re effectively two independent circuits. They share a common line to the transformer but have different connections to the door chime.

One Button

And at the door chime itself we can see how the three wires all get together:


Measuring this

Now if this was a simple DC circuit then we could (with suitable resistor dividers) just measure the voltage on the wire going from the doorbell to the chime. But it isn’t; it’s AC. So we’re going to have to be a little more clever.

Fortunately there exist sensors that can measure current. There are some that sit in the circuit, and there are some that can wrap around a cable and use a “hall effect” sensor to detect current flow.

This latter is what I used. The one I used looks a lot like this and uses a “CT103C” sensor:


This provides a small analogue signal that can be measured by a simple sketch on an Arduino or similar. Because I have two doorbells and wanted WiFi this meant I needed an ESP32 (the ESP8266 I normally use only has one ADC channel).

The idea is that you put the wire from the doorbell to the chime through the center hole and reconnect it to the chime. Don’t put it on the common wire to the transformer ‘cos then you won’t know what button was pressed.

In practice I found there wasn’t enough space inside the chime cover to hold both sensors, so I used a simple extension wire to let it go outside of the chime case.

You can now do an analogRead() on the pin. Typically when the button isn’t pressed you’ll see a value close to zero (it may be a little higher if you have a lighted doorbell button). But when you press the button the value jumps a lot. In my case it went to over 400. This makes it easy to detect a button push.

Other considerations

We also want to add a short “debounce” delay; this will stop “unclean” press/release from triggering the event too quickly. And, hey, we’ve all seen that impatient person ringing the doorbell multiple times per second… we can stop that as well!

Because of my home automation setup, I just made the ESP32 send a message to my MQTT server. The exact topic that will be used will depend on the MAC address of the ESP32 used, but in general it will send a “pressed” message

The resulting sketch is here.

What can we use this for?

In Home Assistant we can set up automation tasks. In the automation section, a setup such as

- alias: Back Doorbell
  initial_state: true
    - platform: mqtt
      topic: doorbell/123456/back_doorbell
      payload: 'pressed'

- alias: Front Doorbell
  initial_state: true
    - platform: mqtt
      topic: doorbell/123456/front_doorbell
      payload: 'pressed'

is sufficient. We don’t need to create sensors, just have the automation triggered directly.

Now we can do anything that Home Assistant is configured for.

If you use my Alexa Virtual Buttons skill then you can have Alexa trigger anything it controls (even speak “Back door bell pressed”). Or you could have flash lights (useful for deaf people). Or if you have a smart TV then you could pop up a message; e.g. with an LG OLED TV and my code fork you can do something like:

    - service: rest_command.alexa
        command: "pushcontactbyname"
        param1: "Front Door"
        param2: 0
    - service: shell_command.tv_toast
        message: "Front doorbell"

as the action. If you’re out of home you could have it send a text message, or use the Home Assistant application to create a notification (although they’re not so quick, sometimes!)


Home Assistant also logs activity. In the logbook you may see entries such as

Back Doorbell has been triggered by mqtt topic doorbell/123456/back_doorbell
6:59:19 PM - 

Or if you’re into SQL…

MariaDB [hass]> select time_fired,event_data from events where event_type='automation_triggered' and event_data like '%doorbell%mqtt topic%';
| time_fired                 | event_data                                                                                                                  |
| 2021-07-08 22:59:19.544307 | {"name": "Back Doorbell", "entity_id": "automation.back_doorbell", "source": "mqtt topic doorbell/47C708/back_doorbell"}    |
| 2021-07-08 23:00:08.090737 | {"name": "Front Doorbell", "entity_id": "automation.front_doorbell", "source": "mqtt topic doorbell/47C708/front_doorbell"} |

You now have a record of every time your doorbell was pressed!


This isn’t a fully smart doorbell… but it gets part way there, and isn’t dependent on any cloud provider. Local control!