Door Bell Repeater | WiFi Bell

by Tesalex in Circuits > Wireless

963 Views, 2 Favorites, 0 Comments

Door Bell Repeater | WiFi Bell

WiFi Bell Square.jpg

Hi! In my home, I have a doorbell on the ground floor, but my room is on the first floor. The sound of the doorbell fails to reach if the room’s door is closed, and that has caused me some inconvenience in the past, to say the least. So, I decided to do something about it. As the wiring for doorbell is not there on the first floor, wired options are out of the question. I could buy a wireless doorbell, but being an engineer I am, I decided to make my own solution for it. I wanted a bell that would trigger when the ground floor bell triggers. For the communication method, I could either use RF or Wi-Fi. As I have used RF in my previous projects, I decided I would go with Wi-Fi this time. Please note that this project makes use of the AC Detection Circuit I explained in my previous Instructables. If you haven’t seen it yet, make sure you do. And without any further ado, let’s get into the project.

Supplies

20220529_110845705_iOS.jpg
20220529_110849658_iOS.jpg

Please find the list of parts required with affiliate links below.

INDIA:

ESP-01: https://amzn.to/3HshxLI

220V to 5V module: https://amzn.to/3HtUbFg

Relay: https://amzn.to/3xwaayi

PC817: https://amzn.to/3zCXwjD

LM317: https://amzn.to/3QpdjZe

CR2032 cell: https://amzn.to/3QqRTLh

Cell holder: https://amzn.to/3xXnFs8

US:

ESP-01: https://amzn.to/3QucpdV

220V to 5V module: https://amzn.to/3b6Pbu7

Relay: https://amzn.to/3xTAmnR

PC817: https://amzn.to/3xVJzMd

LM317: https://amzn.to/3MY0JNL

CR2032 cell: https://amzn.to/3ObRPNO

Cell holder: https://amzn.to/39sUmEm

UK:

ESP-01: https://amzn.to/3zXW77B

220V to 5V: https://amzn.to/3tFNIkV

Relay: https://amzn.to/3zCYVGV

PC817: https://amzn.to/3MWgLaH

LM317: https://amzn.to/39qxAx7

CR2032 cell: https://amzn.to/3O11A1h

Cell holder: https://amzn.to/3MT30tn

Watch the Video

Door Bell Repeater | WiFi Bell

I have made a video detailing all the steps. Please take a look.

A Word From Sponsor

20220529_095754194_iOS.jpg

This video is sponsored by PCBWay. If you want professional looking PCBs for your projects, visit their website and without a second thought, order the PCBs. You can choose the solder mask color, PCB thickness, number of layers and so much more. It is very easy to order PCBs too. Just click on quote now and enter the details, or you can use the quick order option on their website. Once ordered, you will receive them in no time. So go ahead and order your PCBs today.

The Concept

IMG_0447.PNG

Let’s start with the working concept of the project. The bell switch we use here is used to complete an AC circuit, which momentarily connects the bell to power and then it rings. The ESP01 on the first floor will create an access point that the ground floor ESP01 will connect to and send data to it when the bell switch is pressed. I will use my AC detection circuit here to detect that the switch is pressed and use it as an input to the ESP-01 Wi-Fi module. On receiving this input, it will send a packet to the to the access point. After the packet is received, the ESP-01 will close a relay coil for 3 seconds mimicking the action of a bell switch, which in turn will ring the bell I will install next to it. Now to power the circuit on the first floor it will not be a problem as there is a power socket close to where I want to install it. But for the ground floor, there is no power socket nearby, so I will use a 3.3V CR2032 coin cell. But again, the problem arises with the mAh of this cell which is very low. We will tackle this problem with the software, which I will explain in the coding section.

The Code

The code is a very important aspect for this project. For communication we will use UDP protocol. It can easily be facilitated using the UDP library for Arduino IDE. This is the first time that I am using this library and I will put a link to all the websites I referred to for writing this code. Let’s first look at the code for the ground floor ESP01. Its job is simple – Connect to the AP created by another ESP01 and send a packet to it when the switch is pressed. To save power though, we will put the ESP01 to deep sleep 10 seconds after sending the packet, also it will go to deep sleep if it cannot connect to AP within 15 seconds. The ESP01 uses very less power in deep sleep and that should make our coin cell last much longer. But to bring it out of deep sleep, we must reset the ESP01. So instead of using AC detection circuit as an input, it will be used to reset the ESP01. After reset, the ESP01 will send a packet and go to deep sleep again and the cycle continues. This is why all the code resides in setup() body and not in the loop body. Rest of the code is just connecting to WiFi or some debug statements.

For the first floor ESP01, the code is a bit more complicated. The first thing it has to do is to create an access point and then keep listening for data on the port where we are sending the packets from another ESP01. If any data is received it must drive the peripheral attached to GPIO2 high for 3 seconds. But driving ESP01 GPIO pins not that easy, and I learned it the hard way. You see, you can’t just use digitalWrite(HIGH) on the pins of ESP01. There are certain rules which we have to follow while using the GPIO pins. The GPIO0 and GPIO2 are internally tied high, and we don’t want to interfere with it. So, if you want to control anything at all using these two pins, you must connect the device between Vcc and the GPIO pins. The opposite is true for the third GPIO pin – GPIO15. This is the reason why I am writing HIGH in the setup() section and when a packet arrives, I am writing LOW to it, and again writing HIGH after 3 seconds. I strongly suggest everyone to read this small webpage thoroughly before trying to use any GPIO pins of ESP01. There is a lot of unique behavior for ESP01 that we cannot even think of. I did not and I paid the price by spending two days on debug.

The Code in Action

I have uploaded the code to the respective WiFi modules. Both the modules are powered from my DIY Bench Power supply. The one that will receive packet is also connected to Arduino serial port to see when the packet is received. Let’s fire up the Arduino and turn on the power supply. I will open the serial monitor and reset the packet sending module, and soon in the serial monitor we can see our packet received. The AP is also visible in the WiFi devices list. This means our code is working just fine. Now I have connected an LED to the GPIO2 pin of AP module. As soon as we reset the other module, LED turns on for 1 second and then it turns off as per our code. We can also connect the other module to serial port of Arduino and visualize it sending the packet in Serial monitor. Now that our code is working fine, let’s move on to the circuit building.

The Circuit

IMG_0456.jpg
Schematic_WiFi Bell_2022-06-16.png
20220529_095811141_iOS.jpg
20220617_144336389_iOS.jpg
20220617_144339971_iOS.jpg
20220617_144345388_iOS.jpg
20220617_144350337_iOS.jpg

I ordered a beautiful black perfboard from PCBWay for this project. It looks astonishing! Download the gerber files attached, upload it to PCBWay website and select solder mask color as black to receive this awesome looking perfboard in no time. To solder on this, we need our two WiFi modules which I have labelled beforehand to avoid confusion. Additionally, the AC detection circuit, a CR2032 coin cell and holder, a 5V relay and a diode to be used as a flyback diode, a 230V AC to 5V DC converter module, some screw terminals, and headers is required. The circuit for the module sending packet is very easy. I cut a piece of the perfboard and completed the circuit. Let’s try it out.

I will insert the 3.3V cell in its holder, and we see a packet received in the serial monitor. Now, I have connected wires to the screw terminal, and I will mimic the bell switch now, meaning I will apply AC power for 1 second to the board. It resets and another packet is received. Now that this circuit is ready to go, let’s understand the next circuit.

Another circuit will be powered by a 230V AC socket, hence, to bring it down to 5V DC I am using a power supply module which then gets converted to 3.3V using this LM317 circuit. I didn’t have a 75-ohm resistor, so I am using two 150 ohms in parallel. The 3.3V is then used to power the WiFi module which then drives the relay through its GPIO pin. For ESP01, driving things with GPIO pins is a completely different story as I have already mentioned. I went through lots and lots of iterations to drive the relay reliably. I played with 1 transistor, 2 transistors, NPN & PNP transistors, resistor values, resistor placements and everything you can think of. Finally, this comment brought my misery to an end, and I went with the opto-isolator circuit and the relay is turning on and off reliably now. Also, all ESP01 have a flickering issue in their GPIO pins, means when turning on, the GPIO pins go low for about 100ms. To avoid this, I have used a 1000uF cap between GPIO2 and Vcc. Read this page for more information on it.

I completed the circuit and applied 230V in the input, and currently there is no power in the bell terminals. I’ll put the battery in the other circuit, and we see this LED light up for 3 seconds as expected. The 3.3V cell is completely discharged it looks like, not a shocker as I abused it a lot. So anyways, I will apply the 3.3 using my power supply. After applying the power, we can see that the relay switches on giving us 230V AC on the output terminals for 3 seconds. With this test our project is complete. Now you can install it in the place you desire.

Thank You!

That was all for this Instructables. If you find it informative, please like, share, and subscribe. Drop any questions you have in the comment below and I will try to answer it. Till next time!

Supporting Links

https://create.arduino.cc/projecthub/pratikdesai/how-to-program-esp8266-esp-01-module-with-arduino-uno-598166

https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/udp-examples.html

https://www.electronicshub.org/esp8266-deep-sleep-mode/

http://www.forward.com.au/pfod/ESP8266/GPIOpins/index.html

https://forum.arduino.cc/t/driving-5v-relay-with-esp-01/696874/6