In this NodeMCU ESP8266 project, I have shown how to make the Blynk NodeMCU IoT projects with DHT11 & LDR control relay. With this NodeMCU project, you can control two home appliances from the smartphone and push buttons. You can also monitor the real-time temperature and humidity in the Blynk App And also control the relays with temperature in AUTO mode.

Blynk NodeMCU IoT projects

With this home automation system, you can control the relays with 2 modes.

  • Manual Mode
    • Control relays from the Blynk app and push buttons manually.
  • Auto Mode
    • Control relays with the DHT11 sensor and LDR automatically.

Circuit of this Blynk NodeMCU IoT projects

Circuit of this Blynk NodeMCU IoT projects

The circuit for this NodeMCU Blynk IoT-based home automation project is very simple.

I have used D5 & D6 GPIO to control the 2 relays. And the GPIO D0, D7 & D8 connected with pushbuttons to control the relay module and to change the mode manually.

The SD3 connected with DHT11 temperature sensor and A0 connected with LDR.

The OLED connected with D1 & D2. Here OLED is optional.

Then input voltage in 12V DC. And I have used 7805 regulator to fed 5V supply to NodeMCU and sensors.

Required Components for this NodeMCU Project:

Required Components for the NodeMCU 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 (1-no)
  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″)

Tutorial video on Blynk NodeMCU Home Automation

In this tutorial video, I have explained how to use NodeMCU to make the IoT project. How to configure the Blynk app to control any home appliances through the internet. Also explained how to get sensor data in the Blynk App and program the NodeMCU with Arduino IDE.

PCB for the NodeMCU IoT Projects

Program NodeMCU with Arduino IDE

For this IoT based home automation project, I have used the Arduino IDE to program NodeMCU.

First update the Preferences –> Aditional boards Manager URLs: https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json

Then install the ESP8266 board from the Board manager or Click Here to download ESP8266 Board.

After that install the following libraries.

  • Blynk Library: Click Here to download.
  • DHT11 Sensor Library: Click Here to download.
  • Adafruit_SSD1306 (for 0.96″ OLED display): Click Here to download.
  • SH1106Wire Library (for 1.3″ OLED display): Click Here to download.

In the code, you have to enter the AUTH TOKEN & WiFi credentials.

#define AUTH "AUTH TOKEN"                 // You should get Auth Token in the Blynk App.  
#define WIFI_SSID "WIFI NAME"             //Enter Wifi Name
#define WIFI_PASS "WIFI PASSWORD"         //Enter wifi Password

And you can modify the predefined temperature and light intensity limit as per your requirement.

//Set values for Auto Control Mode
const float maxTemp = 34.10;
const float minTemp = 33.8;

const int maxLight = 1000;
const int minLight = 200;

After entering this details, upload the code to NodeMCU.

Connect Home Appliances with Relay

Connect Home Appliances with Relay

Now, connect 2 home appliances with relay module as per the above circuit.

In Auto mode, Relay-1 can be controlled with room temperature, so I have connected a Fan with Relay-1. And Relay-2 can be controlled with LDR (Dark sensor), so I have connected a lamp with Relay-2.

Please take proper safety precaution while working with high voltage.

Control Relays with Blynk App and Pushbuttons

Control Relays with Blynk App

In manual mode, you can easily control the home appliances from the smartphone using Blynk App. And you can also monitor the real time status of switches in the Blynk app when you control the relays manually from push buttons.

Control Relays with LDR and DHT11 temperature sensor

Control Relays with LDR and DHT11

In Auto Mode, the NodeMCU compares the predefined maximum and minimum temperature values with the temperature sensed by the DHT11 sensor. And accordingly, control the Relay-1.

And the Relay-2 controlled by the LDR as per the predefined value mentioned in the code.

I hope you like this Smart house IoT projects idea with the ESP8266 and Blynk app.

Click Here for more such ESP8266 projects.

Please do share your feedback on this IoT project. Thank you for your time.

This Post Has 3 Comments

  1. Uwe Straube

    Hello, I liked the project very much. But it would be perfect if you could still set the temperature using a slider in the Blynk app. For example between 30 and 50 degrees Celsius. Sorry my english is bad. Uwe

  2. Uwe Straube

    Good Day, here its a ERROR
    display.print(modeDecode(switchMode));
    Thank Uwe

  3. Uwe Straube

    Arduino: 1.6.9 (Windows 10), TD: 1.35, Board: “NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200”

    C:\Users\Uwe Straube\AppData\Local\Temp\Temp1_Code_NodeMCU_Blynk_SmartRelay_V4.zip\Code_NodeMCU_Blynk_SmartRelay_V4\SmartRelay_0.96_OLED\SmartRelay_0.96_OLED.ino: In function ‘void changeMode()’:

    SmartRelay_0.96_OLED:90: error: ‘modeDecode’ was not declared in this scope

    display.print(modeDecode(switchMode));

    ^

    exit status 1
    ‘modeDecode’ was not declared in this scope

    Dieser Bericht wäre detaillierter, wenn die Option
    “Ausführliche Ausgabe während der Kompilierung”
    in Datei -> Voreinstellungen aktiviert wäre.

Leave a Reply