Hello friends!! Welcome to Tech StudyCell. in this video we
will make another home automation project with ESP32 and NodeMCU. in the previous video,
I have already shown you, how to connect multiple NodeMCUs with the same Blynk account. but in this video, I will show you, how to
connect both ESP32 and NodeMCU with the same Blynk account to control all your appliances. let me show you how it works. First, I will control the room-1 appliances
with the Blynk App and you can see, I can easily control these lamps from the Blynk
app. next, I will control the room-2 appliances again from the Blynk App. and you can see
I can easily control the NodeMCU with the same Blynk account.
Now I will control the room-1 appliances from
the manual switches. you can see, I can also monitor the real-time
status in the Blynk app. now let me control the room-2 appliances, and again I can monitor
the real-time status in the Blynk app. Now, let me turn off the internet and show
you, how it works without internet. After turning off the Wi-Fi, I can only control
these lamps from the manual switches. let me show you, I can easily control the lamps
from the manual switches. Let me show you, I can easily control the
lamps from manual switches, if the Wi-Fi is not connected. thus we can easily control appliances if Wi-Fi
is not available. let me turn on the Wi-Fi again, after turning
on the Wi-Fi, you can see, the blue LED turns on. and I can control these lamps from Blynk
app. you can see, I can easily control the lamps for room-1 and also for the room-2.
During the video, I will share the complete
circuit diagram for both NodeMCU and ESP32 and also share the code, that I have used
for this project. after watching this video, if you can easily
make this project for your home. so let's get started. to make this home automation project we need
a microcontroller for each room, so you can use NodeMCU or ESP32 as a microcontroller
and you also need a relay module. for NodeMCU, we have to use a 4 channel relay module but
if you use ESP32, you can use both 4-channel or 8-channel relay module. and you can use
the existing switchboard to control the appliance manually. in the circuit, you can see, I have connected
the ESP32 devkit with the 4 channel relay module and I have used these GPIO pins to
connect the relay module with ESP32.
Each switch connected across the GPIO pin
and ground. and I have not used any pulled-up resister
with these switches, as I will use the INPUT_PULLUP function in the code. and this is the 220
or 110 volts AC circuit. you can see, this is the LIVE and this is
a neutral wire. and I have connected these 4 lamps with the relay module. you can refer
to this circuit.
Please take proper safety precautions while
making this AC circuit. now if using ESP32 then you can also connect
an 8-channel relay module with ESP32. but in this project, I will use a 4 channel
relay module to control 4 appliances using ESP32. and for room-2, I will use NodeMCU
and a 4-channel relay module to control 4 appliances. and You have to connect the switches
across the GPIO pins and ground. There is one limitation with this circuit,
that Switch-2 should be turned off during the booting process of NodeMCU. so during the restart for uploading the code
to NodeMCU, this S2 switch should be turned off, otherwise, the booting process will fail.
and if you face any issues with the SD3 pin then you can use the D4 instead of SD3. you
can see, I have connected the ESP32 with the 4-channel relay module and the switches as
per the circuit.
So this is a common ground and these are the
GPIO pins from ESP32. so each switch is connected across the ground
and GPIO pin from ESP32. so you can easily make the circuit. but if you want to avoid these connections,
then you can use these PCBs. with PCB you can control four home appliances and with
this, you can control 8 home appliances. So if you want, you can download the Gerber
file for these 2 PCBs from the description and order it from the jlcpcb. you can order
any custom design PCB from JLCPCB with three simple steps. First, upload the Gerber file, then select
the parameters like quantity, PCB masking color. then place the order. if you select a faster delivery service, then
you will get the PCB within a week. and as you can see the quality of the PCB
is very premium in this affordable price range. so you can always try jlcpcb for any custom
design PCB project. in this project for room-1 and I will use
this circuit and for room-2, I will use this PCB, as I don't have any extra 4 channel relay
module. for this project I will use the same Blynk project which I have created in my previous
video, to control 2 NodeMCUs using the same Blynk account.
You can find the previous video link in the
description. now in this project, you can see if I tap
on any button, you can see, I have used virtual pin, and to turn off the relay, I will send
"1" and to turn on the relay I will send "0", as I am using active low relay module. and
mode is "Switch". so in this way, you have to create 8 buttons
using virtual pin V1 to virtual pin V8. I have shown all the steps in my previous
video. and while creating this project I have selected
the device as NodeMCU but as we are using only virtual pins, so you can control any
microcontroller with this project.
Now I will upload the code to ESP32 and NodeMCU
for this project. this is a code for ESP32 and this is the code
for the NodeMCU. you can download both codes from my website
iotcircuithub.com. just visit the article and you can download the code from this button. before uploading the code to ESP32 first,
you have to download and install the ESP32 board and Blynk and Acebutton libraries. after that you can see I have defined all
the GPIO pins connected with the relay module and switches.
And as I said I will use the first four buttons
to control the ESP32. so here you can see, I mentioned virtual pin
V1 to virtual pin V4. Here you have to enter the authentication
token sent by the Blynk. after that you have to mention the Wi-Fi credentials, here you
have to mention the Wi-Fi name and Wi-Fi password. if you refer to the same circuit, then after
doing these changes, you can directly upload the code to ESP32.
So let me connect the ESP32 with my laptop. now I will go to Tools, select the board as
DOIT ESP32 devkit V1, and the proper PORT. now I will hit the upload button. now, here it showing Done uploading. now I will remove the ESP32 and connect NodeMCU
with my laptop. now let me open the code for NodeMCU here
you can see, this is the code for the NodeMCU. here I have defined all the GPIO Pins connected
with the switches and relay module. and here you can see I am using the virtual pin V5
V6 V7 and V8 to control the NodeMCU from the Blynk app.
Now if you use another microcontroller
for your third room then create another set of buttons in the Blynk App and change this
virtual pin number accordingly. after that, if I go down, here, I have mentioned
the authentication tokens sent by the Blynk. so here you can see, this is the authentication
token so the authentication token must be same for all microcontrollers. you can see in the ESP32 have used the same
authentication token and in NodeMCU I am also using the same authentication token. but you can use different Wi-Fi credentials
or you can use the same Wifi credential, this is totally up to you. after doing these changes you can directly
go to Tools, select the board as NodeMCU 1.0, you can see, this is the board.
And select the proper port, then hit the Upload
button. again if you face any problems, then, please
refer to my previous tutorial video on programming NodeMCU and ESP32. and while programming the
ESP32 and NodeMCU don't connect both microcontrollers with the laptop at the same time. as you can see I have conducted the ESP32
with the room-1 appliances and NodeMCU with room-2 appliances. you can also use a 4 channel relay module
instead of this PCB for room-2. and you can also use multiple smartphones to control these
appliances. you just have to log in to the same Blynk
account. let me tap on login and you can see this is
the project we have created. so I can also control these appliances from
this smartphone. now let me turn on the appliances for room-1,
you can see, I can easily turn them on. let me turn on the appliances for room-2.
so I can easily control the appliances from
the smartphone as you can see. now I will control the appliances from the
manual switches. and you can see the real-time status in the
Blynk app. You can also join our Telegram channel Tech
StudyCell. I do upload different circuit diagrams of
iot projects in the channel. if you find this project helpful please hit
the like button and share it with your friends. don't forget to subscribe for more such videos. thank you for watching, have a great day..