In this video I'm going to hack a cheap
doorbell and integrate it into Home Assistant. Make sure you stick around, and
if you like what you see, hit subscribe button below so you don't miss out on
future videos! Hi I'm Will from Will Surridge Tech, and
today we're going to look at a cheap doorbell that I bought from Wilko; and
hack it to make it smart. We're going to stick a Wemos D1 Mini in the back of it,
and integrate it into Home Assistant. We can then look at using node-red to make it
do some smart things. Let's get going. Let's start off by having a look at the
doorbell. I got this doorbell from Wilkinson's for ยฃ12.
I could have
got a slightly cheaper one, but this one came with both the mains-powered
receiver, and a battery-powered receiver. I thought it'd be interesting
to have a look at them both to see how the circuitry differed and see which one
might be easier to hack later on. Let's start off having a look at the mains
powered receiver. We're going to try it out and see how it functions normally.
It
appears to have an LED that's always on and the speaker that chimes when the
button is pressed. Let's take it apart. I'm going to take it apart and have it
plugged in. This is obviously dangerous because the live components will be bare.
If you're not comfortable playing with mains voltage then don't do this. We can
confirm with our volt meter that the LED stays at a constant voltage throughout
and it doesn't change when you hit the doorbell.
We can also check the voltage
that I transformer outputs, in my case it's outputting 12 volts. This is useless
because we want to power our Wemos D1 Mini which runs at 5 volts. So all
in all, we can't tell if the doorbell has been rung using an LED easily, we can't
power our D1 Mini from the power supply built in, and we'll be fiddling around
with mains voltages – why bother doing that. Let's have a look at the battery
powered receiver instead. This version also has an LED and a speaker, but the
LED only turns on when the doorbell is run – ideal; it also runs on two AA
batteries which is 3 volts – ideal; and if we remove these batteries we have a nice
compartment to sit our Wemos D1 Mini in – ideal.
If we have a look inside
there's a really nice circuit board where everything that we need access to
is attached by tails – the power in, the LED out, and the speaker out. Power is
going to be easy – we're going to power our D1 Mini using a USB cable, and
we going to attach the ground pin and the 3.3 volt pin on our D1 Mini to the
power supply of our receiver.
Now we can have a look at the LED. This is how we're
going to know if the doorbell has been rung. We want to check the voltage on
both pins of the LED using the ground of the D1 Mini as reference. You would
expect your voltages to go from 0 volts when the LED is off, to about 3.3
volts when the LED is on. Mine, however, is a bit different.
Both of my pins start at 4.5 volts when the LED is off, and then when
the LED is on, one of the pins drops to 2.5 volts. This obviously
creates a potential difference to allow the LED to light up, but it's not very
useful when it comes to determining how we can use our Wemos D1 Mini to detect
that. Unfortunately it means we're going to require a bit more soldering than I'd have hoped. if your LED is normal and it starts at 0 volts and then goes up to
a 3.3 volts or something like that then you can just connect your D1 Mini pin
directly to one of the pins on the LED that changes and you can detect whether
it goes high or low like that.
If you have a strange setup like mine then
you're going to need a PNP transistor and a small resistor, I'm using 560 ohms.
We're going to connect the emitter of the transistor to the anode of the LED
or a positive constant high voltage source, we're going to connect the base
through our 560 ohm resistor to the cathode of the LED, and then we're going
to connect our collector to the pin on the D1 Mini. We're going to need a
pulldown resistor to avoid any noise on our circuit, I'm going to use pin D8 on
up my D1 Mini as this has a pulldown resistor built in.
We're going to solder
the transistor directly onto the LED on the circuit board and then we're going
to attach a long tail to come out to connect to the D1 Mini later on.
Make sure these tails are long enough – you can always cut them down later. If we
connect the doorbells power supply to the 3.3 volt pin on the D1 Mini and the
ground to the ground pin, and then we connect on you tail to the LED on pin D8
we can test it out! I'd recommend using a breadboard for now or
any form of crimp connector just to try it out. We can always tidy it up and make
a permanent connection later on. We need to plug the USB into the computer and
head over to ESPHome.
Once here, we can add a new device, naming the node, selecting
the board type is a Wemos D1 Mini, entering up Wi-Fi SSID and password,
and clicking submit. We can then compile and download our binary. Once we've got
it downloaded we open up ESPHome- flasher, select the right serial port,
select the right binary that we've just downloaded, and click flash. Once the pink
Wi-Fi information appears on the screen you can close it down and test it out.
After this we head back over to ESPHome as we need to add a sensor.
If we go to
the ESPHome's website we can see under binary sensors there's some yaml that
we can copy. If we paste this into our configuration file, we change the name to
doorbell, change the pin to d8, and add a pin mode for a pulldown resistor. Once
happy we can save it validate it and upload it over the air to our D1 Mini.
Once that's happened we can head over to our integrations and see it it should
appear automatically in the integrations.
But if it doesn't you can add it using
the big plus at the bottom right and searching for ESP home. In here you add
the IP address of your new device and then it should pop up. if we click
through we can see the doorbell sensor listed as a binary sensor. If we hit the
button on our doorbell then the binary sensor should go from off to on. If that
works we can move on to the next feature of our doorbell – controlling the speaker.
For this we're going to add a switch to pin D4, we're going to compile it
and upload it over the air to our D1 Mini. Once that's happened we should see
that the switch is listed as a new entity under our device in our
integrations. Now we can play with the circuitry. For this we're going to need
an NPN transistor, we're going to connect it in series with our speaker, so the
emitter will be connected to the speaker wire, the collector will be connected
to the speaker terminal, and the base will be connected to pin D4 on our D1
Mini.
If the base pin is high then the signal can flow between
when the collector in the emitter and the sound should happen. If the pin D4 is
low, then no signal will flow, and no sound will come out, but the binary sensor
should still detect, and the LED should still light up. We can now test out in
Home Assistant, checking the sound plays when the switch is on, and the sound
doesn't play when the switch is off. If that works we can put it all together.
Now my battery compartment isn't actually big enough for my D1 Mini using
header pins so I'm going to solder my cables directly onto the D1 Mini. I'm
going to need to drill a hole through the battery compartment for the cables
to come through, and another hole out to the side for my USB cable to come in.
With a lot of jiggery-pokery and a bit of cable extension
(hindsight's unkind), it should all fit and it should all work.
It's worth
testing it out again now to double-check that nothing's come loose during this
process. There's no point in having a smart doorbell if all we're going to do
is turn the sound on and off, so let's head over to node-red and create some
automations. I want my doorbell to notify my phone when the door bell is rung and
also to announce a text-to-speech alert on my Google home Mini, but only if the
sound is turned on on the doorbell. We're going to need an event state node, a
current state node, and two call service nodes. The event state node will trigger
the automation if the doorbell is on ie the doorbell has been rung, the current
state node will determine if the doorbell sound is on and so whether to
trigger the text-to-speech alert or not. Now the first call service node is going
to be our text-to-speech.
We're going to trigger the
text-to-speech on our Google home Mini, and set the message to the message we
wanted to play. In our second call service note we want to do the same
thing but using the notify function on the phone app. Once we're happy we can
link it all together and deploy it. We can test it out. If the doorbell sound is
off then you should just get a notification on your phone, if the
doorbell sound is on then it should also trigger a text-to-speech alert on the
Google home Mini.
And there we go – a cheap doorbell turned smart. Make sure you hit
subscribe below so you can find out more about my smart tech and how you can
build yourself the ultimate smart home!.
As an Amazon Associate I earn from qualifying purchases.