Temperature And Humidity Monitoring System Using NodeMCU And Blynk

In this project, we will build a cool temperature and humidity monitoring system using the NodeMCU development board. This project contains an ESP8266 NodeMCU, 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 Blynk cloud through the 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

Temperature And Humidity Monitoring System
Temperature And Humidity Monitoring System

Circuit Diagram

Temperature And Humidity Monitoring System Circuit Diagram
Temperature And Humidity Monitoring System 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 give 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.

You can view the Gerber file from here Gerber File Viewer.

PCB View

Temperature And Humidity Monitoring System 2D View
Temperature And Humidity Monitoring System 3D 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 hobbyists.

Standard quality for any product needs to be maintained using some parameters. PCBWay gives that opportunity by quality control in designing and manufacturing. At first, they ensure accuracy, clarity, 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 Tester, X-Ray Inspection Machine, Automated Optical Inspection (AOI) Machine. They are having 50+ new engineers on the daily basis around the world using PCBs for their work, who trust for their reliable quality.

Features of PCBWay

PCB Prototyping & Manufacturing: PCBWay produces FR-4 and Aluminum boards and advanced PCBs like Rogers, HDI, 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 clients themselves.

Open Source Community: It not only offers PCB Prototype & Assembly service 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 their products. It takes only 3 to 15 days according to 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.

The 4th PCBWay contest is finally here. This year, they have introduced mainly two themes of the entries: One is IoT, which will include home automation, wearable or other interesting projects and the other one is robotics, which could be combined with smart cars, drones or other automated projects. For enquiries about the rules and regulations and prize pools just check out this link PCBWay 4Th PCB Design Contest.

Guide for Ordering PCB From PCBWay

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, just 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 Gauge and LCD widget.

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 temperature Gauge as A0 and 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; Adafruit Sensor LibraryBlynk LibraryDHT11 Library, I2C Library.

#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

#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.

LiquidCrystal_I2C lcd(0x27, 16, 2);
DHT dht(D3, DHT11);
BlynkTimer timer;

I2C module and DHT11 temperature sensor are defined here.

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.

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.

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. It is important to set up an LCD display through the I2C module to show the result. So this code is for setting up the LCD and serial monitor.

void loop() {
  Blynk.run();
  timer.run();
}

The Blynk library will run in this loop function.

Video Output

Leave a Comment