ESP32

ESP8266 and ESP32 as Transmitter and receiver, Home Automation Project

ESP8266 and ESP32:

ESP8266 and ESP32 as Transmitter and receiver, Home Automation Project- I have been using the Nodemcu ESP8266 and ESP32 WiFi + Bluetooth Modules for years in different IoT based projects for monitoring different types of sensors and for controlling AC and DC loads.

Today’s project is completely different from my previous projects; because this time round, we are not using any IoT platform.

ESP8266 and ESP32

These two boards will connect with each other through Wi-Fi, and one more thing I’d like to mention is that we don’t need a WiFi router or a hotspot for this project.




Anyway, we are going to use ESP8266 as the Transmitter and ESP32 WiFi + Bluetooth module as the receiver.

On the transmitter side, I have connected some switches with the ESP8266 WiFi module.

ESP8266 and ESP32

On the receiver side, I have connected 110/220Vac bulbs with the ESP32 WiFi + Bluetooth module. You can also connect DC loads; it depends on what you want to control.

ESP8266 and ESP32

Anyway, let’s proceed to power up the transmitter and receiver sides. When the 110/220Vac supply is connected, never touch the relay contacts because such high voltage can be fatal. So, as far as possible wear protective gloves and perform such high voltage experiments in the presence of a friend or any companion.

On the transmitter side, you can small toggle switches; this will reduce the size, and also the cost.

Instead of using the ESP32 WiFi module on the receiver side, you can also use the ESP8266. However, one advantage of using the ESP32 module on the receiver is that you can modify it in the future. As you may know, the ESP32 also includes a Bluetooth module. So you can design your own Android application for controlling the loads. This way, you’ll be able to control the loads both from the transmitter and your Smartphone.

ESP8266 and ESP32

I successfully controlled all the 4 Bulbs wirelessly, the communication was insanely fast, and there was no false triggering. In comparison to regular Bluetooth modules, its range is also greater. Now, let’s go ahead and take a look at the connections.



Amazon Links:

ESP32 WiFi + Bluetooth Module(Recommended)

ESP8266 WiFi Module

4 channels relay module

*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.

ESP8266 Transmitter Circuit:

ESP8266 and ESP32

The 4 switches are connected to the Nodemcu ESP8266 WiFi module digital pins D1, D3, D5 and D7. This is the 5V regulated power supply based on the 7805 linear voltage regulator. This power supply is optional. While performing your initial experiments you can use your Laptop or PC to power up the Nodemcu ESP8266 Wifi module. You can also use a power bank, lithium ion battery, or a Lipo battery to power up the Nodemcu module.



ESP32 Receiver Circuit:

ESP8266 and ESP32

It doesn’t matter if you don’t have a development board like this, you can do the same exact connections on a breadboard.

ESP8266 and ESP32

4 SPDT type relays are connected to the ESP32 GPIO pins 12, 13, 14, and 27. You must connect AC or DC loads between the common and normally open contacts of the relays. These are the freewheeling diodes connected across the relays coil pins. You can use 1N4007 diodes. I am using a pair of 10K ohm and 2N2222 NPN transistor to control each relay. You can follow this circuit diagram.



If you want to use the Arduino IDE for programming the ESP32 and ESP8266, then first you will need to install these boards in the Arduino IDE. Because, by default no ESP32 and ESP8266 boards are installed in the Arduino IDE and you can confirm this by going to the Tools Menu… then to Board and you can see there are no ESP32 and ESP8266 boards in the list.

ESP8266 and ESP32

So, first we will need to add it in the boards list, for this copy this Board Manager URL link;

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

Then go back to the Arduino IDE, go to the File Menu, then preferences, and paste this link in the Additional Boards Manager URLs and click the Ok button.

ESP8266 and ESP32

Next, go to the Tools Menu, then Board and click on the Boards Manager. Search for the ESP32. You can see we have Arduino ESP32 Boards and ESP32 by Espressif Systems.

ESP8266 and ESP32

So, make sure you install this one and don’t forget to select the latest version. Finally, the board installation has been completed and now we can confirm this by going to the boards list.

ESP8266 and ESP32

You can see all the different variants of the ESP32 Boards have been added.




ESP8266 Board Installation:

Now, let’s install the ESP8266 Board, just follow the same exact steps but this time we will use a different board manager URL link given below.

http://arduino.esp8266.com/stable/package_esp8266com_index.json

So, copy the above link, go back to the Arduino IDE. Go to the File Menu, and then preferences. Paste the link in the Additional Boards Manager URLs. Don’t forget to put a comma if there is already a link.

ESP8266 and ESP32

Next, go to the Tools Menu, then Board and click on the Boards Manager. Search for the ESP8266.

ESP8266 and ESP32

You can see the ESP8266 boards have also been added in the list.

ESP8266 and ESP32

Now, we can use the Arduino IDE for programming the ESP32 and ESP8266 WiFi modules.



MAC address Finder:

You will need this program to find the MAC address of the receiver. In this project, I am using ESP32 module as the receiver. So, I will simply upload this program into the ESP32 board. Then I can open the Serial monitor and copy the MAC Address.

ESP8266 and ESP32

You can see the mac address is 98 : F4 : AB : 68 : F4 : A4

On your side, this address may be different. So, make sure, you replace this mac address with yours. Don’t forget to remove the colons and add 0x with the numbers. As you can see in the transmitter side programming. 

0x98, 0xF4, 0xAB, 0x68,0xF4,0xA4



ESP8266 Transmitter Programming:



ESP32 Receiver Programming:




Watch Video Tutorial:

 

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button