How to Make IoT Based Home Automation With NodeMCU Sensors Control Relay

by techstudycell in Circuits > Microcontrollers

7417 Views, 58 Favorites, 0 Comments

How to Make IoT Based Home Automation With NodeMCU Sensors Control Relay

IoT based Home Automation with Blynk and NodeMCU control Relay | Real-Time Feedback
Pic 4.jpg
Pic 3.jpg
vlcsnap-2020-07-16-11h16m13s153.png

In this IoT based project, I have made Home Automation with Blynk and NodeMCU control relay module with real-time feedback. In the Manual Mode, this relay module can be controlled from Mobile or smartphone and, Manual switch. In Auto Mode, this smart relay also can sense the room temperature and sunlight to turn on and off the fan and light bulb.

This smart home project has the following features:1. Home appliances controlled from Mobile using Blynk App 2. Home appliances controlled by temperature & Humidity sensor automatically (In Auto Mode) 3. Home appliances controlled by Dark Sensor automatically (In Auto Mode) 4. Monitor LIVE room temperature & Humidity reading on OLED and Smartphone 5. Home appliances controlled with manual switches 6. Control Home appliances through the Internet

Supplies

Required Components for this Smart House project

1. NodeMCU

2. DH11 Sensor

3. LDR

4. 10k Resistors 5 no

5. 1k Resistors 5 no (R1 to R4)

6. 220-ohm Resistors 2 no (R5 & R6)

7. Optocoupler PC817 2 no

8. BC547 NPN Transistors 2 no

9. Diode 1N4007 2 no

10. Diode 1N4001 1no

11. LED (1.5v) 3 no

12. Capacitors 100uF 2 no

13. SPDT 12V Relays 2 no

14. 7805 voltage regulator 1 no

15. Push Switch/ button 4 no

16. Connectors & jumpers

17. OLED I2C Display (0.96" or 1.3")

Circuit Diagram

Pic 2.jpg

This is the complete circuit diagram for this IoT based home automation project.

I have used NodeMCU to control the relay module. I have connected the DHT11 temperature & humidity sensor and LDR to control the relay automatically according to the room temperature and ambient light. There four pushbuttons connected with NodeMCU i.e, S1, S2, CMODE, RST. S1 & S2 to control the relay module manually CMODE to change the Mode (Manual Mode, Auto Mode) RST to reset the NodeMCU I have supplied 12V to the relay module and used a 7805 voltage regulator to supply 5v to NodeMCU.

Make the Circuit on Breadboard for Testing

Pic 17.jpg
gtrfd.jpg

Before designing the PCB, first I have made the circuit on the breadboard for testing. During testing, I have uploaded the code to the NodeMCU then tried to control the relays with the pushbuttons, Blynk App, temperature sensor, and LDR.

Download the attached Code for this NodeMCU project.

I have mentioned all the link of the required libraries in the code.

Install the Blynk App

Pic 5.jpg
Pic 6.jpg

Install the Blynk App from Google play store or App store then add all the required widgets to control the relay module and monitor the temperature and humidity. I have explained all the details in the tutorial video.

I have used the 3 button widgets to control the relay module and change the mode. And 2 gauge widgets to monitor the temperature and humidity.

Different Mode of the Smart Relay Module

modes.jpg

We can control the smart relay in 2 modes:

1. Manual Mode

2. Auto Mode

We can easily change the mode with the CMODE button fitted on the PCB or from the Blynk App.

Manual Mode

Pic 8.jpg
Pic 11.jpg

In the Manual mode, we can control the relay module from the S1 & S2 push-buttons or from the Blynk App.

We can always monitor the real-time feedback status of the switches from the Blynk App. And we can also monitor the temperature and humidity reading on the OLED display and the Blynk App as you can see in the pictures. With the Blynk App, we can control the relay module from anywhere if we have the internet on our smartphone.

Auto Mode

kok.jpg
vlcsnap-2020-07-16-11h20m54s293.png

In Auto mode, the relay module controlled by the DHT11 sensor and LDR.

We can set a predefined minimum and maximum temperature and light values. In Auto mode when the room temperature crosses the predefined maximum temperature the relay-1 turns on and when the room temperature becomes lesser than the predefined minimum temperature the relay-1 turns off automatically.

In a similar way when the light level decreases the relay-2 turns on and when the light is sufficient the relay-2 turns off automatically. I have explained in details in the tutorial video.

Designing the PCB

Pic 10.jpg

As I am going to use the circuit daily, so after testing all the features of the smart relay module on the breadboard, I have designed the PCB. You can download the PCB Gerber file of this home automation project from the following link:

https://drive.google.com/uc?export=download&id=1LwiPjXC1JfeQ7q-e-pIqN0J9TTVAHo52

Order the PCB

jlc1.JPG
jlc.jpeg
jlc2.JPG

After downloading the Garber file you can easily order the PCB

1. Visit https://jlcpcb.com 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 Parameters

Pic 15.jpg
Pic 14.jpg

4. Set the required parameter like quantity, PCB color, etc

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

Select Shipping Address and Payment Mode

jlc8.JPG
jlc6.JPG
FMKPK0WKCNDNKTX.LARGE.jpg

6. Type the Shipping Address.

7. Select the Shipping Method suitable for you.

8. Submit the order and proceed for the payment. You can also track your order from the JLCPCB.com.

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

yuoht.jpg
Pic 13.jpg

After that solder all the components as per the circuit diagram.

Then connect NodeMCU, DHT11, LDR, and OLED display.

Program the NodeMCU

Pic 7.jpg
Pic 16.jpg

1. Connect the NodeMCU with laptop

2. Download the Code. (Attached)

3. Change the Blynk Auth token, WiFi Name, WiFi Password.

4. Change the predefined temperature and light value for Auto Mode as per your requirement

5. Select the NodeMCU 12E board and proper PORT. Then upload the code.

** In this project, you can use both 0.96" OLED and 1.3" OLED display. I have shared the Code for both OLED, upload the code as per the OLED display you are using.

I have already attached the code in the previous steps.

Connect the Home Appliances

Pic 1.jpg

Connect the home appliances as per the circuit diagram. Please take proper safety precautions while working with high voltage.

Connect 12Volt DC supply to PCB as shown in the circuit.

Finally

Pic 9.jpg
Pic 12.jpg

Turn on the 110V/230V supply and 12V DC supply.

Now you can control your 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 query please write in the comment section. For more such projects Please follow TechStudyCell. Thank you for your time & Happy Learning.