Dumb Door Bell 220v to Smart Bell -Will this work?

I have a Ding Dong Door bell which operates directly on 220-230v AC. I would like make the notification smart. The bell will continue to run as it is today, there will be a parallel circuit that will be taking care of the automation and notification via HA. I am thinking to do something like the one I am showing below. Will this work with a relay or SSR? Can we replace the relay/SSR with a transistor as a switch?

Bill of material:

  1. D1 Mini (esp8266)
  2. 5v Charger to power the d1 mini and 5v Relay/SSR
  3. Hi-Link 5v (HLK-PM01)
  4. 5v Relay/SSR

D1_Mini_Door_Bell_Schema.drawio

yaml for d1 mini as bellow.

captive_portal:
web_server:
  port: 80

switch:
  - platform: gpio
    pin: D2
    inverted: false
    id: bell_switch
    name: "Bell Switch"

binary_sensor:
  - platform: gpio
    pin:
      number: D7
      mode: INPUT_PULLUP
      inverted: True
    name: "Bell Relay"
    device_class: power
    on_press: 
      - switch.turn_on: bell_switch
    on_release:
      - switch.turn_off: bell_switch

Updated diagram with push type switch.

Not sure connecting 220V to the PM01 will do what you want.
Assuming pressing the button closes the circuit, your ESP will only be powered when the bell is pressed.
A relay is also not what you want.

You probably want:

  • Independent power supply for the ESP (or parallel but before the bell)
  • an optocoupler to detect when the button is pressed, i.e. when the circuit is closed.
2 Likes

Thanks for replying on this. Yes, I am powering my esp with separate +5v via mobile charger for faster response as well as the d1 mini getting corrupted when we have abrupt power on/off. While waiting for suggestions, I was trying with a 5v relay in my bread board setup without the door bell. I have found the relay only triggers if it receives the input from D1 mini and not by providing +5v as its input. Lesson learnt. :slight_smile: Do you have any recommendations on the optocoupler component?

Any that will accept 220V and output 3.3V.

This or similar should do:

https://www.aliexpress.com/item/32951897813.html

Thanks for the link. I have used the above mentioned model for another circuit. I could find 2 challenges with this component.

  1. This circuit works in reverse logic. That is when the AC is ON, the voltage is zero in the DC side and when the AC is OFF, the voltage is higher in the DC side. Not sure how to use this with the Binary sensor which I have used to trigger in the yaml above.
  2. The logic is bit slow when the AC is applied and removed. Since we have a bell switch which is momentarily pressed and released, esp will be able to sense it?

I have tested the above given yaml and automation in HA without the relay part. If I connect the D7 (GPIO13) to ground, the automation is getting triggered. So we need a way to ground the GPIO13 via electronic switch that operates on 3v or 5v. We will get this 3v or 5v from the Mains via HLK-PM01.
Will it be OK, if we use NPN transistor as a switch which will be fast enough to trigger? If so do you have any recommendation with the transistor circuit?

I lost you. Where do you want to insert a transistor? What would be the base?

If I am right, a transistor can be used as switch. I am trying to find out whether we can use a NPN transistor connected between the GPIO13 and Ground is a possibility. Pardon me, if that is not possible.

Well yes, but no TTL transistor will take 220v on its base. Maybe with the voltage reducer, but that seem funky

I would first try with the optocoupler. Just simulate the doorbell with a plain switch.

That’s why I am trying to provide the DC input to TTL transistor connected with Hi-Link HLK-PM01 that will give us the 5v DC output from 220v AC.
I will go with your suggestion. I will connect the AC side of Optocoupler with Phase and Neutral.
At the optocoupler DC side, the vcc to D1 mini 3.3v, out pin should be given to A0 of D1 mini and the ground to common ground on the D1 side? Is my understanding correct?

D1 Mini ---- Optocoupler
3.3v ---------- VCC
A0 ------------ Out
Gnd ---------- GND

I have reconnected my breadboard with different set of jumper wires this time. I have powered the 5v relay +ve and Gnd from D1 mini itself. I have connected the AC converted into DC via a wall charger +5v to IN1 of the Relay 1. Gnd is connected to D1 mini Ground. There is an automation job setup to trigger a audio notification. I can confirm this is working as expected. Thanks to Chris for sharing his views.

alias: Dev - Smart Bell Notification
description: ""
trigger:
  - platform: device
    type: turned_on
    device_id: 3c550268c2941f395822129e29e0ebb2
    entity_id: b7fa1a3b7be0c3698d9d7dcf025e178e
    domain: switch
condition: []
action:
  - service: media_player.play_media
    data:
      media_content_id: http://xx.xx.xx.xx:8123/local/sounds/airplane_chime.mp3
      media_content_type: music
    target:
      entity_id:
        - media_player.jukeboxonrpi4
        - media_player.jukeboxonrpi5
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: media_player.media_stop
    target:
      entity_id:
        - media_player.jukeboxonrpi5
        - media_player.jukeboxonrpi4
    data: {}
  - service: tts.google_say
    data:
      cache: false
      entity_id: media_player.jukeboxonrpi5
      message: "Hi, There is someone at the Main Door. "
      language: en-in
mode: single

This gets complicated by the fact the the doorbell button completes the circuit of the power source in series with the doorbell solenoid. ref.

In the USA we have a step down transformer to 24V-AC to drive the doorbell. You probably do, too because it’d be a little risky to run 220V to a place where someone is pushing a crappy button.

Here’s an idea. Power the esp8266 independently. Use a current sense device. This is as simple as wrapping a wire, many times, around one of the wires that is part of the button/solenoid/power-source circuit. The ends of this sense device wire, with a series resistor, go to the input of the opto-isolator. It will take a bit of experimenting to get the number of wraps and value of the series resistor.

The output of the opto-isolator will be a 50 (60?)hz square wave. Software on the esp8266 could figure out “if this square wave exists the door bell button is being pushed” to prevent multiple triggers. and “only notify if a notification has not be sent in the last x seconds”

I use Tasmota and C++ (Arduino IDE) on the esp8266. Tasmota has an easier interface to Home Assistant, but C++ is easier to program.

Have fun!

OSD

I know it could be the safest way of operating the doorbell giving the DC side of the switch for someone to press. However, in my part of geographic its 220v AC directly given to a coil that produces electromagnetic induction that pulls a plunger. You can find a video posted by a youtuber here.(I know how he is handling the cables directly with AC voltage and risk associated with that when the other wire is open circuited via the coil). In my case the operating switch is already having 220V AC even today. I have taken caution and put a high quality switch there to avoid any electrocution.

Back to this automation, With the circuit I have shared above, there is a Hi-Link AC to DC converter that will be placed before the D1 mini. The D1 mini and 5v relay module (with optocoupler) will have separate DC power that is connected to my UPS and will not be sharing the power with the Door bell. With the optocoupler already in place, any short circuit in the Hi-Link may not be impacting the D1 side of the circuits. This way the door bell will function without any interference with Automation (as it is today). I may use the automation that I am discussing here to take a snapshot via a camera placed near to my door bell switch using HA automation in future.

Why not just use shelly for this? I am using shelly plus 1 to ring 230V doorbell.

OP is trying to detect a ring, not provoke one.
That’s why a relay makes no sense.

Why to waste 5v power supply and relay?

This is how I did it from my AC doorbell using optocoupler. AC doorbell to DC to 433mhz device My Doorbell used 18V and I didn’t fancy running a esp off it so I modified a 433 door sensor. It has worked well.

Might be worth having a look here → DIY Smart Doorbell for just $2, no soldering required

A very simple and safe way to detect electrical AC current in a wire is to use a “Current Switch” like the one linked below. You can then simply enable the internal pullup on the ESP8266 Digital GPIO pin, connect a wire from that pin to the dry contacts of the current switch, and then connect another wire from the ESP8266 GND pin to the other dry contact terminal on the current switch.

https://www.amazon.com/Miniature-Current-Normally-Monitoring-Detectable(M3050)/dp/B0BG7YGTR7/ref=sr_1_3?crid=CDNUTGMLM4L8&dib=eyJ2IjoiMSJ9.2tqIBThOjsnpq1lZU3cs8CkTODFQ8hpOx1qFy2bojLRERZ16LuMPaMQr8OhGU-5Ph7cD_EH0YrODD2Dw9BBB7BWYx4rMlCEUT-2VcReWntuDrPPWPlcJb3UxndzoAOdEDdSvbrR2KLXwQctq3ie23rHzylX8oTv4QwYlCVDGPEzNsq7icTOwM66toJUjSU_u6SkJOZy_qR-qasKPGC6l1MrSZxJZFsVw2FWK04KqN5Y.c5fe4QH6KiRKBLWafovWt08xlbWjJDCp8ciqFid4mr4&dib_tag=se&keywords=current%2Bswitch%2Bdry%2Bcontact&qid=1727267524&sprefix=current%2Bswitch%2Bdry%2Bcontact%2Caps%2C102&sr=8-3&th=1

Someone else solved it simply by added a reed switch…