In this IoT project, I have shown how to make IoT-based Smart Home Automation using Multiple NodeMCU ESP32 network to control all the home appliances from the switches & Blynk 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:
- Connect multiple ESP32 and NodeMCUs with the same Blynk account.
- Control home appliances with WiFi (Blynk App)
- Control home appliances with manual switches.
- Monitor real-time feedback in the Blynk App.
- Control home appliances manually without internet.
- You can connect any number of microcontrollers in this IoT network as per the requirements.
For each room, you just need a relay module & a microcontroller like ESP32 or NodeMCU to make this smart home project.
Required Components:For each room, you just need an ESP32 or NodeMCU, relay module & switches to make this smart home project.
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.
Required Components for the PCB1. Relays 5v (SPDT) (8 no)
2. BC547 Transistors (8 no)
3. PC817 Optocuplors (8 no)
4. 510-ohm 0.25-watt Resistor (8 no) (R1 - R8)
5. 1k 0.25-watt Resistors (10 no) (R9 - R18)
6. LED 5-mm (10 no)
7. 1N4007 Diodes (8 no) (D1 - D8)
8. Push Buttons (8 no)
9. Terminal Connectors
10. 5V DC supply
Required Software:1. Arduino IDE
2. Blynk App
Circuit Diagram of the ESP32 Control RelaysThe 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 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.
Please take proper safety precautions while working with high voltage.
Circuit Diagram of the NodeMCU Control RelaysThe circuit is very simple, I have used the GPIO pins D1, D2, D5 & D6 to control the 4 relays.
And the GPIO pins SD3, D3, D7 & RX 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.
Multiple NodeMCU ESP8266 NetworkNow 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 Blynk App.
Control Relays With Internet Using BlynkIf the ESP32 or NodeMCUs are connected with the WiFi, then you can control the home appliances from Blynk App.
You also use multiple smartphones to control the appliances with Blynk App. For that, you have to login 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 App.
Control Relays Manually With SwitchesYou can always control the appliances manually with switches.
If the WiFi connected. then you can also monitor the relay time status of each switch in the Blynk App.
Controlling Relays Without WiFiIf the WiFi is not available, you can control the relays from the switches.
The NodeMCU will check for the WiFi after every 3 seconds. When the WiFi is available, the ESP32 or NodeMCU will automatically connect with the WiFi.
Configure the Blynk App for the Multiple NodeMCUs1. Install the Blynk App from the Google play store or App store. Then create an account.
2. Sign In and Tap on the New Project.
3. Give the name to the project, select NodeMCU, Connection type will be WiFi. Then tap on Create.
4. Blynk will send an authentication token to the registered email id. Tap on OK.
**As we will use only virtual pins in this Blynk project, so we can control both ESP32 and NodeMCU with this Blynk project.
Add the Button Widgets in Blynk App to Control RelaysThen add 8 button widgets from the Widget Box to control the 8 relays.
Create buttons with V1, V2, V3, V4, V5, V6, V7, V8 pins to control the relays.
Select the Mode as Switch for all the buttons.
**Here I have used an active low Relay module, so to turn ON the relay we have to send “0” and “1” to turn OFF the relay.
I have used virtual pins V1, V2, V3, V4 to control the first relay module with ESP32 (Room-1).
And V5, V6, V7, V8 to control the second relay module with NodeMCU (Room-2)
I have explained all the details in the tutorial video.
Code for Blynk NodeMCU & ESP32 Home AutomationIn 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
- ESP8266 Board
- ESP32 Board
Then install the following libraries
- Blynk Library
- AceButton Library
I have mentioned all the download links in the code.
Then enter the WiFi name, WiFi password & Blynk Auth Token in the code.
Enter the following WiFi credential and Authentication token in the code:
- WiFi Name at “WiFi Name”
- WiFi Password at “WiFi Password”
- Auth Token sent by Blynk at “AUTH TOKEN“
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.
For each NodeMCU or ESP32, you have to change the virtual pins in the code. In this project for the ESP32, virtual pins will be V1, V2, V3, V4. And for the NodeMCU, virtual pins will be V5, V6, V7, V8.
And while programming, please don't connect both microcontrollers with the laptop at the same time.
PCBs for This Home Automation ProjectAs I said, you can make this smart home system just by using the Relay module and ESP32 or NodeMCU.
But to make the circuit compact and give the project a professional look, you can use the PCBs for this project.
Designing the PCBTo make the circuit compact and give a professional look, I have designed the PCB after testing all the features of the smart relay module on the breadboard.
You can download the PCB Gerber file of this home automation project from the following link:
https://drive.google.com/uc?export=download&id=1Jx4D_DSV_ei1y0a82AbtxbsNhy8sjCmY
Order the PCBAfter downloading the Garber file you can easily order the PCB
1. Visit https://jlcpcb.com/RHS and 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 Parameters4. Set the required parameter like Quantity, PCB masking color, etc.
5. After selecting all the Parameters for PCB click on SAVE TO CART button.
Select Shipping Address and Payment Mode6. 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 order page.
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 PCBAfter that, I have soldered all the components as per the circuit diagram.
Then connect the NodeMCU board with the PCB.
Connect the Home AppliancesConnect the 4 home appliances with the relay module as per the circuit diagram. Please take proper safety precautions while working with high voltage.
Connect 5-volt DC supply with the PCB. (I have used my old mobile charger)
Control Appliances With Blynk AppHere I have used the ESP32 for room-1 and NodeMCUs for room-2 to control appliances for 2 rooms.
If you have 3-rooms, then you add one more ESP32 or NodeMCU in the IoT network.
Thus, you can connect multiple NodeMCU and ESP32 as per your requirement.
Finally!! the Smart Home system is readyNow you can control all the home appliances in a smart way.
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 queryplease write in the comment section. Thank you & Happy Learning.
Comments