Home Automation Using Esp8266 & Blynk2.0 App
IoT Home Automation using Blynk & NodeMCU ESP8266
Introduction
In This Project, You Learn Full Home Automation using blank App & NodeMcu(esp8266). This Project is the Most Common & Popular Project Across The Internet. Home Automation Mean We Controlled Home Light, Measuring the GAS Level, Measuring Temperature & humidity And Measuring the Water Tank Level.
In This Project, We are Measuring The 4 Parameter And Controlling the two applications. all possibilities will be done by wifi Through I mean the NodeMcu is InBult Wifi Controller. And When The Wifi is Connected to the NodeMcu We Control The Applications And Measuring The Parameter Anywhere in the World. All Data will Show in Blyank2.0 App.
Bill Of Materials
S.N | Component Name | Quantity | Link To Buy |
1 | NodeMcu (esp8266) | 1 | |
2 | 16x4 LCD Display | 1 | |
3 | Ultrasonic Sensor | 1 | |
4 | MQ-2 Sensor | 1 | |
5 | DHT-22 Sensor | 1 | |
6 | 2-Channel Relay Module | 1 | |
7 | Buzzer | 1 | |
8 | Zero Pcb | 1 |
Block Diagram
The Block Diagram for The Project is Given Below. Using The Block Diagram We Just Decide on The Input And Output Components.
I Mean Which Sensor We Used on the Input Side Like DHT22 Sensor, Ultrasonic Sensor, or MQ-2 Sensor And Output Side We Used a 16×4 Lcd Display, and 2 Channel Relay Module To Turn ON/OFF The Home Application.
Circuit Diagram
Now Will Discuss The Circuit Diagram Of The Project. We are ready to Decide on the INPUT/OUTPUT component in Block Diagram. Now I will Explain and Show The Pin Connected to The Sensor With NodeMcu.
DHT-22 Sensor Will Providing The Digital Value That’s Why I connected to the digital PIN D3 PIN Of Nodemcu. And is given The Output in the Form Of Temperature And Humidity.
Ultrasonic Sensor They Will Also Be a Digital Sensor That’s Why I connected the PIN D6 and D5. I mean Trigger Pin Will Connected To PIN D6 And Echo Pin Will connect to PIN D5.
MQ-3 Sensor They Will Provide Digital Value And Analog Value. This Project is required the Analog Value That’s Why I connected the A0 PIN. In NodeMcu We Have Only One Analog Pin Not More Analog Pin.
2-Channel Relay Module Is an Output Device And When You Give a ‘0’ signal to The Input Then Relay Will On if you give a ‘1’ Then Really will OFF. And Output Side Of Relay We Just Connected the Home Applications They Work On AC Or Dc Voltage.
Relay Will Connected the PIN D7 And D8.
In This Project, I used The Small Buzzer And The Will Connected To PIN D0.
PCB Design
Setting Up Blynk App Application
Now It’s Time To set up Blynk Application.
If you Used To Laptop Then You are required To The Link https://blynk.cloud/dashboard/login Login to The Blynk Application.
- When You Login The Application We just Make A New Device If You Used Nodemcu just Type it Esp8266 And if you Used ESP32 Then Type It ESP32.
- Go To The Template Just Press The Your New Device And Edit It
- You Just Add The Switch And Gauge And Define The Virtual Pin Like V0, V1…..
- When you have Done All Things You Just Save The File And Go To The MyDevice And Just Click The Your Template Then you See The Proper Output of The Application.
If You Used Mobile Application You Just go To our Playstore Search for it Blynk App and Download The Application.
Blynk ApplicationYou Just Sign In with the Same User Name And Password And Used The Application
Source Code / Program
When You Upload the Code To Your Controller Fist You Need To Change The Those Things.
Your Blynk App Auth Token
Wifi User Name
Wifi Password
1 2 3 |
char auth[] = "A45V5tHcYpxM7E_7DYth14iBEdUx6v"; char ssid[] = "prateek"; char pass[] = "justdoelectronics"; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
//Prtaeek //www.justdoelectronics.com #include <LiquidCrystal_I2C.h> #define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> #include <DHT.h> LiquidCrystal_I2C lcd(0x27, 16, 4); char auth[] = "A45V5tHcYpxM7QbE_7DYth14iBEdUx6v"; char ssid[] = "prateeksingh"; char pass[] = "singh@@12345"; DHT DHT(D3, DHT22); BlynkTimer timer; #define Buzzer D0 #define MQ2 A0 #define trig D6 #define echo D5 #define relay1 D7 #define relay2 D8 void setup() { Serial.begin(115200); lcd.begin(); lcd.backlight(); pinMode(Buzzer, OUTPUT); pinMode(trig, OUTPUT); pinMode(echo, INPUT); pinMode(relay1, OUTPUT); pinMode(relay2, OUTPUT); digitalWrite(relay1, HIGH); digitalWrite(relay2, HIGH); Blynk.begin(auth, ssid, pass, "blynk.cloud", 80); DHT.begin(); lcd.setCursor(0, 0); lcd.print("Welcome To "); lcd.setCursor(4, 1); lcd.print("Our Projects"); delay(4000); lcd.clear(); timer.setInterval(100L, gassensor); timer.setInterval(100L, DHT11sensor); timer.setInterval(100L, ultrasonic); } void DHT11sensor() { float h = DHT.readHumidity(); float t = DHT.readTemperature(); if (isnan(h) || isnan(t)) { Serial.println("Failed to read !"); return; } Blynk.virtualWrite(V2, t); Blynk.virtualWrite(V3, h); lcd.setCursor(0, 1); lcd.print("Tem Level:"); lcd.print(t); lcd.setCursor(-4, 2); lcd.print("Hum Level:"); lcd.print(h); } void ultrasonic() { digitalWrite(trig, LOW); delayMicroseconds(4); digitalWrite(trig, HIGH); delayMicroseconds(10); digitalWrite(trig, LOW); long t = pulseIn(echo, HIGH); long cm = t / 29 / 2; Blynk.virtualWrite(V0, cm); lcd.setCursor(-4, 3); lcd.print("Water Level:"); lcd.print(cm); lcd.print(" "); } void gassensor() { int value = analogRead(MQ2); Serial.println(value); value = map(value, 0, 1024, 0, 100); if (value <= 55) { digitalWrite(Buzzer, LOW); } else if (value > 70) { digitalWrite(Buzzer, HIGH); } Blynk.virtualWrite(V1, value); lcd.setCursor(0, 0); lcd.print("Gas Level:"); lcd.print(" "); lcd.print(value); } BLYNK_WRITE(V5) { bool RelayOne = param.asInt(); if (RelayOne == 1) { digitalWrite(relay1, LOW); } else { digitalWrite(relay1, HIGH); } } BLYNK_WRITE(V4) { bool RelayTwo = param.asInt(); if (RelayTwo == 1) { digitalWrite(relay2, LOW); } else { digitalWrite(relay2, HIGH); } } void loop() { Blynk.run(); timer.run(); } |
Demo Of Project
This One Is The Final Hardware Of this Project
- Here We Just interfaced DHT-22 Sensor And You just See the Mobile Will Display The Temperature & Humidity.
- Now I just Interfacing the Ultrasonic Sensor And You Check Out The Output Of IN 16×4 Display And Mobile Applications.
- Now I just Interface MQ-2 Sensor And You Just Check Out The Output Of the MQ Sensor In the Display As well As the Mobile Application.
- Now Is True to Relay This Image Will See the Real Will Be Off Motor And the Light Will Also be Off.
- When I press the Mobile Application Switch They Will On And Turn On The Motor.
- When I Press the Light Switch in Mobile Application They Will On And Light Will Turn On
- This One Is The Final Output We See All Parameter Display In a 16×4 Lcd Display.
Video Tutorial
ESP8266 Related Projects