Home Automation With NodeMCU Touch Sensor LDR Temperature Control Relay

Introduction: Home Automation With NodeMCU Touch Sensor LDR Temperature Control Relay

About: This Page is for different Electrical and Electronics Projects, DIY, Circuits, etc. All the projects are explained with circuit diagram, Breadboard schematic, working principle, Arduino sketches so it becomes …

In my past NodeMCU projects, I have controlled two home appliances from Blynk App. I received many comments and messages to upgrade the project with Manual Control and adding more features.

So I have designed this Smart Home Extention Box.

In this IoT based home automation project, I have made home automation using Blynk & NodeMCU with Touch Sensor, LDR, Temperature control relay module with real-time feedback.

In the Manual Mode, this relay module can be controlled from a mobile or smartphone and, manual touch switch (TTP223).

In Auto Mode, this smart relay also can sense the room temperature and sunlight to turn on and off the fan and light bulb using the DHT11 sensor & LDR.

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 manually with touch switch

6. Control Home appliances through the Internet (WiFi)

This project is inspired by this Simple NodeMCU project

Supplies

1. NodeMCU Board

2. DH11 Sensor

3. LDR

4. 10k Resistors 5 no

5. 1k Resistors 3 no

6. 220-ohm Resistors 2 no

7. BC547 NPN Transistors 2 no

8. Diode 1N4007 2 no

9. Diode 1N4001 1no

10. 5-mm LED (1.5v) 3 no

11. SPDT 5V Relays 2 no

12. Push Switch/ button 4 no (or) TTP223 Touch Sensor (3no)

13. Connectors & jumpers

14. OLED I2C Display (0.96" or 1.3") (Optional)

15. Hi-Link 220V to 5V AC to DC converter

Step 1: Circuit Diagram

This is the complete circuit diagram for this IoT based smart home system.

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.

You can also connect the TTP223 Touch sensors instead of pushbuttons.

CMODE to change the Mode (Manual Mode, Auto Mode)

RST to reset the NodeMCU

I have used a 110V/220V AC to 5V DC converter to supply the 5V to NodeMCU and relays.

So you can connect directly 110V or 220V AC supply with this smart relay module.

Step 2: Make the Circuit on Breadboard for Testing

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, touch switch. Blynk App, temperature sensor, and LDR.

Here RST pin is active low, so the Touch sensor connected with the RST pin should be active low.

Download the attached Code for this NodeMCU project. I have mentioned all the links of the required libraries in the code.

Step 3: Tutorial Video for This IOT Project

In the tutorial video, I have explained all the steps for making this Smart Home device in detail.

So you can easily make this IoT project for your home.

Step 4: Install the Blynk App

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.

Step 5: Different Mode of the Smart Relay Module

We can control the smart relay in two 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.

In auto

Step 6: Manual Mode

In the Manual mode, we can control the relay module from the S1 & S2 touch switches 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.

Step 7: Auto Mode

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 the code.

Temperature Control

When the room temperature crosses the predefined maximum temperature the relay-1turns on and when the room temperature becomes lesser than the predefined minimum temperature the relay-1 turns off automatically.

LDR Control

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.

Step 8: Designing the PCB

After testing all the features of the smart relay module on the breadboard, I have designed the PCB to make the circuit compact and give the project a professional look.

You can download the PCB Gerber file of this IoT based home automation project from the following link:

https://drive.google.com/uc?export=download&id=1EJY744U5df6GYXU8PtyAKucyPrD-gViX

Step 9: Order the PCB

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.

Step 10: Uploading the Gerber File and Set the Parameters

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

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

Step 11: 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 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.

Step 12: Solder All the Components

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

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

Step 13: Program the NodeMCU

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.

Step 14: Connect the Home Appliances

Connect the home appliances as per the circuit diagram.

Please take proper safety precautions while working with high voltage.

Here you can directly connect 110V or 220V AC supply.

** I have not used touch sensor for the RST pin as it is active LOW.

Step 15: Place the Complete Circuit Inside a BOX

I have placed the complete circuit inside a plasic box. As I will use this NodeMCU project as Smart extention BOX.

It will be very useful and easy to use.

Step 16: Finally

Turn on the 110V/230V 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.

Remix Contest

Participated in the
Remix Contest

1 Person Made This Project!

Recommendations

  • Back to School: Student Design Challenge

    Back to School: Student Design Challenge
  • Micro:bit Contest

    Micro:bit Contest
  • Lamps and Lighting Contest

    Lamps and Lighting Contest

4 Comments

0
cberkay
cberkay

5 months ago on Introduction

WRONG Connection !
DH11 Sensor VCC must connect to 3.3V, not 5V !
Add one 4k7 pull-up for DHT22.

0
cberkay
cberkay

Question 6 months ago

How to modify code for coop door opener with LDR?

0
artisanpallet
artisanpallet

11 months ago

Cool Project...
Thank you for Sharing...

0
techstudycell
techstudycell

Reply 11 months ago

Welcome....