In this IoT project, I have shown how to make IoT-based Smart Home Automation using MultipleESP32 NodeMCU ESP8266 networks to control all the home appliances from the switches & Blynk IoT App. If the internet is not available, then you can control the home appliances from manual switches. During the article, I have shown all the steps to make this smart home system.

This complete Home Automation system has the following features:

For each room, you just need a relay module & a microcontroller like ESP32 or NodeMCU to make this smart home project.

So if you follow all the steps, you can easily make this IoT project just by using ESP32 or NodeMCU and relay module. Or you can also use a custom-designed PCB for this project.

Although the PCB is not mandatory, I have used PCB to make the circuit compact and give the project a professional look.

Required components for the ESP32 control 4 Relays PCB

Required components for the NodeMCU control 4 Relays PCB

Multiple ESP32 NodeMCU ESP8266 Network

Now if you have multiple rooms, then you can use either ESP32 or NodeMCU for each room and then repeat the same circuit for each room.

If you use ESP32 then you can use either a 4-channel or 8-channel relay module, but for the NodeMCU you have to use the 4-channel relay module.

There is no limitation on the number of ESP32 or NodeMCUs that can be connected. All microcontrollers will connect to the Blynk server using the same Authenticate Token.

So we can control each NodeMCU or ESP32 independently from the Blynk IoT App.

Circuit Diagram of the ESP32 Control Relays

The circuit is very simple, I have used the GPIO pins D23, D22, D21 D19 to control the 4 relays.

And the GPIO pins D13, D12, D14 & D27 are connected with switches to control the 4 relays manually.

I have used the INPUT_PULLUP function in Arduino IDE instead of using the pull-up resistors.

I have used a 5V mobile charger to supply the smart relay module.

If you use the momentary pushbutton then just connect the pushbutton across the GPIO pins and GND instead of switches.

Please take proper safety precautions while working with high voltage.

Circuit Diagram of the NodeMCU Control Relays

For the NodeMCU, I have used the GPIO pins D1, D2, D5 & D6 to control the 4 relays. And the GPIO pins SD3, D3, D7 & RX are connected with push buttons to control the 4 relays manually.

I have used the INPUT_PULLUP function in Arduino IDE instead of using the pull-up resistors.

I have used a 5V mobile charger to supply the smart relay module.

The D3 pin should not be connected with GND during the booting process of NodeMCU.

If you use latched switch then just connect the switches across the GPIO pins and GND instead of pushbuttons.

Create New Template for ESP32 in Blynk Cloud

For this smart house project, I have used the Blynk IoT Cloud Free plan. Click on the following link to create a Blynk Cloud account.

https://blynk.cloud/dashboard/register

Steps to Create New Template in Blynk IoT

You will get the BLYNK_TEMPLATE_ID and BLYNK_DEVICE_NAME after creating the temple.

**Although, I have selected ESP32 for creating the Template but you can also use this Template for ESP8266, as I will use Virtual Pins for the Datastreams.

Create Datastreams in Blynk Cloud

After that, you have to create Datastreams. Here I will control 8 relays, so I have created 8 Datastreams to control 8 relays.

You have to create the Datastreams according to the number of relays you want to control.

Steps to Create Datastreams:

Set Up Blynk Cloud Web Dashboard

Steps to configure the Web Dashboard to control 8 relays from Blynk Cloud Dashboard

Then again click on "Save" to save the Template.

Add Device Using Template in Blynk IoT

Steps to add a device in Blynk IoT cloud:

Then in the device info tab, you will get the Blynk Auth Token, Template ID, and Device Name. All these details will be required in the code.

PCBs Used for This IoT Project

To make the circuit compact and give a professional look, I have designed PCBs for the ESP32 and NodeMCU control relays circuit.

You can download the PCB Gerber file of this Lora project from the following link:

GitHub link to Download PCB Gerber File

Order the PCB from JLCPCB

After downloading the Garber file you can easily order the PCB.

1. Visit https://jlcpcb.comand Sign in / Sign up.

2. Click on the QUOTE NOW button.

3. Click on the "Add your Gerber file" button. Then browse and select the Gerber file you have downloaded.

Uploading the Gerber File and Set the Parameters

4. Set the required parameter like QuantityPCB masking colour, etc.

5. After selecting all the Parameters for PCB click on SAVE TO CART button.

Select Shipping Address and Payment Mode

6. Type the Shipping Address.

7. Select the Shipping Method suitable for you.

8. Submit the order and proceed with the payment.

You can also track your order from the JLCPCB

My PCBs took 2 days to get manufactured and arrived within a week using the DHL delivery option.

PCBs were well packed and the quality was really good at this affordable price.

Solder All the Components on PCB

After that, I have soldered all the components as per the circuit diagram.

Then connect the ESP32 or NodeMCU with the PCB.

Codes for This IoT Project Using ESP32 and ESP8266

Download the source codes. GitHub Download link.

In the Tutorial video, I have explained all the steps to program the NodeMCU and ESP32 using Arduino IDE.

Before uploading the code you have to install the following boards in Arduino IDE

Then install the following libraries

I have mentioned all the download links in the code.

In the code, enter the Blynk Auth Token, Template ID, and Device Name

#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME ""
#define BLYNK_AUTH_TOKEN ""

 Then enter the WiFi Name and Password.

char ssid[] = "";
char pass[] = "";

For each NodeMCU or ESP32, you have to change the virtual pins in the code. For the ESP32, virtual pins will be V1, V2, V3, V4. And for the NodeMCU, virtual pins will be V5, V6, V7, V8.

To program NodeMCU select the “NodeMCU 1.0 ESP-12E” board and proper PORT. Then click on the upload button.

To program ESP32, select the “DOIT ESP32 DEVKIT V1” board and proper PORT. Then click on the upload button.

And while programming, please don't connect both microcontrollers with the laptop at the same time.

Set Up Blynk IoT App Mobile Dashboard

Install the Blynk IoT app from Google Play Store or App Store. Then log in and Tap on Developer Mode. Select the template that you have already made Then go to the Widget box (on the right) to add widgets.

Steps to set up Blynk IoT app Mobile Dashboard

If the NodeMCU or ESP32 is connected with WiFi the BLUE LED (Built-in) will turn ON.

Please watch the complete tutorial video for more details.

Control the Appliances With Blynk IoT

If the NodeMCU or ESP32 is connected with WiFi, then you can control the home appliances from Blynk IoT App.

You also use multiple smartphones to control the appliances with Blynk IoT App. For that, you have to log in same Blynk account from all the smartphones. In this way, all smartphones will be sink to the Blynk server.

You can control, monitor the real-time status of the relays from anywhere in the world with the Blynk IoT App.

Controlling Relays Without WiFi

If the WiFi is not available, you can control the relays from the switches or pushbuttons.

The NodeMCU or ESP32 will check for the WiFi after every 2 seconds. When the WiFi is available, the ESP32 or NodeMCU will automatically connect with the WiFi.

I hope you have liked this home automation project. I have shared all the required information for this project.

I will really appreciate it if you share your valuable feedback. Also if you have any queries please write in the comment section.

Thank you & Happy Learning.