Making my doorbell smart

For a while I was playing with the idea to be able to mute the doorbell, and receive a notification on my phone when somebody is at the door. I have this old fashioned doorbell that’s ringing very loud:

Old school doorbell

So I ordered some extra Wemos D1 mini ESP’s and a relay shield and started coding. Since I’ve discovered ESPHome, I intended to use this as number 1 choice before coding manually ๐Ÿ™‚

Wemos D1 mini, headers and a relay shield

For the test setup I used a breadboard to figure out which pins to use and how the code response to it.

Test setup: a wire for input and a led for the output

I’m using esphome for communication between the doorbell and homeassistant. In my design I wanted the doorbell to be able to work without interaction with homeassistant. Therefore I used the homeassistant sensor to be able to mute the doorbell. As long as this boolean is not true, the doorbell will ring. So no message to homeassistant and a message back to the doorbell, no extra delay ๐Ÿ˜‰

  name: deurbel
  platform: ESP8266
  board: d1_mini

  ssid: "<SSID>"
  password: "<PASSWORD>"

# Enable logging

# Enable Home Assistant API


  - platform: gpio
    name: "Deurbel Relay"
    id: relay
    internal: true
    icon: mdi:alarm-bell
      number: D1
      inverted: false
  - platform: gpio
    pin: D2
    name: "Deurbel"
    #device_class: window
#      - delayed_on: 50ms   # THIS DOES THE DEBOUNCE
      - delayed_off: 5000ms # THIS PREVENTS FROM MULTIPLE RANGS
        - if:
              binary_sensor.is_off: mute # IF MUTE DONT RING
              - switch.turn_on: relay
              - delay: 250ms
              - switch.turn_off: relay
  - platform: homeassistant
    name: "Input Boolean From Home Assistant"
    entity_id: input_boolean.mute_doorbell
    id: mute
  - platform: status
    name: "Status deurbel"

It works! Next step: assembling the Wemos and the Relay shield. The relay on the shield is connected to the D1, so that remains the same in my code. For the trigger I used the 3.3v on the D2. D2 is shorted to the ground via a resistor, and is high when pressed on the doorbell. This resister is needed to make sure that the input is only high when doorbell is pressed and is low on release.

The schematic (on multiple requests ๐Ÿ˜‰)

On many request, I’ll explain the working a little more. The relay replaces the button by the door. That part is shown on the right of the schematic. Of course we need a trigger and that’ll be the button by the door. That part is on the left of the schematic.

Schematic of the smart doorbell

The relay

The relay has a N.O. and a N.C. That stands for Normal Open and Normal Closed. Normal open means that that pin/connector is open in the normal state of the relay (not powered). Normal closed means that that pin/connector is closed in the normal state. Therefore we need to use the normal open (N.O.) pin, so that the circuit is only closed when the relay gets power.

Using the N.C. would result in continuously ringing of the bell ๐Ÿ˜‰

The trigger

In the code I use, the trigger pin is D2. When D2 is low, the doorbell button/switch is not pressed. When the doorbell button/switch is pressed, the logic state of D2 will be high. Because it is connected via the switch to the 3v3 (please do use 3v3 and not 5v!! The logic ports of an ESP is 3v3 logic).

When not pressed, the port D2 must be low. To ensure it is low (and not floating between high and low) we need to use a resistor to pull the port down.

7 antwoorden op “Making my doorbell smart”

  1. I don’t see this Relay in Hassio, is it supposed to show up as a switch I don’t see the entity id in my states. Please let me know as I want to hook this up to a camera with button so I can get image sent to my phone. Thanks for the esphome yaml I tried a lot of things on the web but yours was the only one that worked. great work!!!!

    Stan Boyd
    – platform: gpio
    name: “Deurbel Relay”
    id: relay
    internal: true
    icon: mdi:alarm-bell
    number: D1
    inverted: false

    1. Hey Stan,

      If you look at the code, you’ll see the option “internal: true”. That makes the switch an internal component. Internal components will not be exposed to the frontend (like Home Assistant). Only specifying an id without a name will implicitly set this to true. I made that choice on purpose. There is for me no need to make the doorbell accessible via Home Assistant. If you do want to make the doorbell make sound for your purpose, then you can remove that line (or make it false, yet I haven’t played with that option myself).

      I’m glad I could help you out with my yaml code ๐Ÿ™‚


  2. Do you have any wiring schematics for this? Would like to use this for my doorbell, I’m just a noob starting using ESP’s do schematics that show how to integrate this in my doorbell system would really help me.

    1. Ok, I didn’t manage to draw a sketch, I’ll will draw one and mail it to you. Yet the schematic is quite easy. It’s a Wemos D1 mini (any esp will do) and a relay shield. Note that if you use another esp, you need to find a relay fitting on that specific esp.

      There is one resistor between the sensor/doorbell-switch pin and ground (to keep it pulled to the ground). Then the 3v3 goes via the doorbell switch to this pin. If the doorbell is pressed, it pulls the pin high, otherwise it stays/goes low.

      The relay is the replacement switch for the doorbell. One wire from the doorbell transformer goes to the doorbell, the other via the relay to the doorbell.

      That’s basically it, nothing more, nothing less…

  3. Hi Marcel,

    Can you give us a drawing? I have an old school doorbell with 8V AC power coming from the adapter, how do i connect this to the LOLIN Relay Shield? NO? NC?

    Please make a complete drawing with 8V input, Wemos, relay shield, chime, button etc.

    1. Hi Johnny B. (Johnny B. Good? ๐Ÿ˜‰ )

      I’ll upload a schematic, as you aren’t the first one to ask.
      Give some time and I’ll place a schematic which explains the bell-part and the button-part.


Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *