In this project, we will build a cool temperature and humidity monitoring system using the NodeMCU development board. This project contains an ESP8266 NodeMCU, a DHT11 temperature and humidity sensor and an LCD display for showing real-time values of surroundings.
Also, we include Blynk software for monitoring real-time data through Android phones. Being IoT-based devices, we can discover and operate this from anywhere in the world through an internet connection.
Must Read IoT-Based Projects
Principle Behind Temperature And Humidity Monitoring System
The principle behind this project is simple. NodeMCU works here as a server. It connects with the Blynk cloud through an internet connection. While ambient temperature is sensed by the DHT11 temperature sensor, it sends the data to the server. Then the LCD display shows the real-time temperature and humidity after processing in the server.
Project
Circuit Diagram
Components Required
- ESP8266 NodeMCU Board
- DHT11 Sensor
- 16×2 LCD Display
- I2C Module
- Wires
- 5V Power Supply
PCB Design
For removing messy wiring and giving a clean look, I designed a PCB prototype for this project. It is also helpful for troubleshooting that runs great without any errors. To design this PCB board, I used EasyEDA as it is too easy to use. For ordering PCB for this, I personally prefer PCBWay.
Gerber file for Temperature And Humidity Monitoring System Using Blynk And ESP8266.
PCB View


Order PCB From PCBWay
This project is sponsored by PCBWay.com. PCBs are required everywhere in the electronics industry. So it needs to be good enough and have to serve the purpose for which they are needed without costing exorbitant amounts. PCBway offers all your needs come true. PCBWay is one of the largest PCB (Printed Circuit Board) manufacturing companies in China. It offers PCB prototype, PCB Assembly, SMD Stencil, and Flexible PCB.
They ship to more than 170 countries worldwide and process more than 2100 PCB orders a day. It feels like PCBWay gives an excellent price and customer service factor in one single serving. I personally ordered PCBs from PCBWay for my projects for just 5 dollars. I’ve used other PCB manufacturers too, but PCBWay has been offering the most reliable and consistent that I have tried. What is also spectacular about PCBWay to me, as a maker and customer, is their service. From their friendly support staff to their intuitive, user-friendly website features, it all counts towards what makes PCBWay an ideal company and brand for any electronics hobbyist.
Standard quality for any product needs to be maintained using some parameters. PCBWay gives that opportunity through quality control in designing and manufacturing. At first, they ensure the accuracy, clarity, and validity of the PCB files that we sent to them.
Then all the boards will go through the most stringent tests other than the basic visual check. They adopt most of the testing and inspecting equipment used in the industry, such as Flying Probe Testers, X-Ray Inspection machines, and Automated Optical Inspection (AOI) Machines. They are having 50+ new engineers on a daily basis around the world using PCBs for their work, who trust their reliable quality.
Features of PCBWay
PCB Prototyping & Manufacturing: PCBWay produces FR-4 and Aluminum boards and advanced PCBs like Rogers, HDI, and Flexible and Rigid-Flex boards, at a very reasonable price. Just check this Instant Quote to order premium PCBs for your hobby projects.
PCB Assembly: It not only offers PCB Prototyping but also offers PCB Assembly service. You can order a full PCB board with attached components by uploading your file. SMT & THT assembly starts from only 30$ including free stencil and worldwide shipping. The components can be sourced and provided by PCBWay, or by the clients themselves.
Open Source Community: It not only offers PCB Prototype & Assembly services but also gives opportunities to students for sponsorships. I think this is so great. They feature their projects on the website also.
3D Printing & CNC: It also produces Rapid Prototyping like 3D printing, CNC Machining, Sheet Metal Fabrication, and Injection Molding. The quality of the product is too premium and reliable. And also the best part is that you will receive your order within a minimum of 3 days.
Services: PCBWay offers great servicing of its products. It takes only 3 to 15 days according to the courier service to deliver your products. Also, it has a live support facility. Whenever you have any problems, you can always reach a live customer service person to respond to your emails or messages. They have the “Return and Refund” principle, for every unusable board caused by PCBWay, they will rebuild and refund the order soon.
Preparing Blynk for Temperature And Humidity Monitoring System
For creating a project on the Blynk platform, you first need to sign up on Blynk. In case if you already have an account on Blynk, sign in using your user id and password. For creating your account, go to www.blynk.com. I used the Blynk app for easy setup.
Click on sign-up if you don’t have an account and if you already have an account, click on sign in. After clicking on sign-up, fill up your details. After this verify your E-mail id and then continue.
Then click on “New Project”, enter the name of the project and choose the connection type and click on “Create”.
Once sign-in after successful account verification, create a new project by clicking the “New Project” button and confirm. Now click on the “+” icon in the right corner and add the Gauge and LCD widgets.
Let’s click the widgets one after another and set up the widget’s settings. First, click on the LCD widget and change its virtual pins to V0 and V1 (values from 0 to 100). Next, click on the Gauge widgets and name them. Set the temperature Gauge as A0 and the humidity Gauge as A1. Also, change the values from 0 to 100. That’s it.
Arduino Code for Temperature And Humidity Monitoring System
Go to File and select Preferences and paste the link “https://arduino.esp8266.com/stable/package_esp8266com_index.json” in Additional Board Manager URLs to add the ESP8266 board. Open Boards Manager from the Tools menu and type ESP8266 to install the ESP8266 platform.
The library files that are needed to compile this code; are Adafruit Sensor Library, Blynk Library, DHT11 Library, and I2C Library.
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 | #include <LiquidCrystal_I2C.h> #define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> #include <DHT.h> LiquidCrystal_I2C lcd(0x27, 16, 2); DHT dht(D3, DHT11); BlynkTimer timer; char auth[] = ""; //Enter the Auth Code char ssid[] = ""; //Enter your WIFI Name char pass[] = ""; //Enter your WIFI Password void weather() { float h = dht.readHumidity(); float t = dht.readTemperature(); int r = analogRead(A0); bool l = digitalRead(D4); r = map(r, 0, 1023, 100, 0); if (isnan(h) || isnan(t)) { Serial.println("Failed To Read From DHT Sensor"); return; } Blynk.virtualWrite(V0, t); //V0 is for Temperature Blynk.virtualWrite(V1, h); //V1 is for Humidity Blynk.virtualWrite(V2, r); //V2 is for Rainfall if (l == 0) { WidgetLED led1(V3); led1.on(); lcd.setCursor(9, 1); lcd.print("L:"); lcd.print("High"); lcd.print(" "); } else if (l == 1) { WidgetLED led1(V3); led1.off(); lcd.setCursor(9, 1); lcd.print("L :"); lcd.print("Low"); lcd.print(" "); } lcd.setCursor(0, 0); lcd.print("Temp:"); lcd.print(t); lcd.setCursor(0, 1); lcd.print("Hum:"); lcd.print(h); lcd.setCursor(9, 0); lcd.print("R:"); lcd.print(r); lcd.print(" "); } void setup() { Serial.begin(9600); lcd.init(); lcd.backlight(); Blynk.begin(auth, ssid, pass); dht.begin(); // Setup a function to be called every second timer.setInterval(10L, weather); } void loop() { Blynk.run(); timer.run(); } |
Code Explanation
1 2 3 4 5 | #include <LiquidCrystal_I2C.h> #define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> #include <DHT.h> |
These include library files that are helping to compile the program.
1 2 3 | LiquidCrystal_I2C lcd(0x27, 16, 2); DHT dht(D3, DHT11); BlynkTimer timer; |
The I2C module and DHT11 temperature sensor are defined here.
1 2 3 | char auth[] = ""; //Enter the Auth Code char ssid[] = ""; //Enter your WIFI Name char pass[] = ""; //Enter your WIFI Password |
Now check your mailbox for Blynk auth token for creating the server. Also, put down your WiFi name and password here.
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 | void weather() { float h = dht.readHumidity(); float t = dht.readTemperature(); int r = analogRead(A0); bool l = digitalRead(D4); r = map(r, 0, 1023, 100, 0); if (isnan(h) || isnan(t)) { Serial.println("Failed To Read From DHT Sensor"); return; } Blynk.virtualWrite(V0, t); //V0 is for Temperature Blynk.virtualWrite(V1, h); //V1 is for Humidity Blynk.virtualWrite(V2, r); //V2 is for Rainfall if (l == 0) { WidgetLED led1(V3); led1.on(); lcd.setCursor(9, 1); lcd.print("L :"); lcd.print("High"); lcd.print(" "); } else if (l == 1) { WidgetLED led1(V3); led1.off(); lcd.setCursor(9, 1); lcd.print("L :"); lcd.print("Low"); lcd.print(" "); } lcd.setCursor(0, 0); lcd.print("T :"); lcd.print(t); lcd.setCursor(0, 1); lcd.print("H :"); lcd.print(h); lcd.setCursor(9, 0); lcd.print("R :"); lcd.print(r); lcd.print(" "); } |
This is the main function of this project. This code will operate the whole process of the system.
1 2 3 4 5 6 7 8 9 | void setup() { Serial.begin(9600); lcd.init(); lcd.backlight(); Blynk.begin(auth, ssid, pass); dht.begin(); // Setup a function to be called every second timer.setInterval(10L, weather); } |
Now come to the setup function. Setting up an LCD display through the I2C module is vital to show the result. So this code is for setting up the LCD and serial monitor.
1 2 3 4 | void loop() { Blynk.run(); timer.run(); } |
The Blynk library will run in this loop function.
Great the way you explain the code makes things clearer
Thanks