How to make a Temperature and Humidity monitoring system using Nodemcu and Blynk

How to make a Temperature and Humidity monitoring system using Nodemcu and Blynk

How to make a Temperature and Humidity monitoring system using Nodemcu and Blynk

Hello, welcome back. In this tutorial, we will learn how to make a Temperature monitoring system using the Nodemcu board and Blynk application. The DHT11 sensor is mainly used for this project. Also, since this project belongs to IoT technology, we can monitor temperature and humidity from anywhere in the world through the smartphone or tablet. We can use this system mainly for animal farms, greenhouses, and factories.

The process of this system

When power ON this system. The Nodemcu board connects to the Blynk app through the internet and Blynk cloud. And then, the Nodemcu board receives values through the DHT11 sensor. Also, those values can be seen on the interface of the Blynk app and on the LCD.

OK, let’s do this project step by step. The required components are given below.

Step 1

Firstly,identify these components.

Step 2

Secondly, connect these components. To do this, use the circuit diagram below.

How to make a Temperature and Humidity monitoring system using Nodemcu and Blynk

Step 3

Thirdly, let’s set up the Blynk app step by step.

  • First, download and install the Blynk app into the smartphone. Then, sign up for this app. Now, run this app and click the “New project” button.
How to make a Temperature and Humidity monitoring system using Nodemcu and Blynk
  • Then, enter the project name. After, select the device type and connection type. Now, click the “confirm” button.
How to make a Temperature and Humidity monitoring system using Nodemcu and Blynk
  • Then, click the + icon in the corner and insert two gauge widgets and one LCD widget.
  • Now, let’s click the widgets one by one and set up the settings in these widgets. First, click the LCD widget and change the pins to V0 and V1. After, enter the values from 0 to 100.
How to make a Temperature and Humidity monitoring system using Nodemcu and Blynk
  • Next, click the Gauge widget one by one and name them. After, change temperature Gauge as A0 and humidity Gauge as A1. Also, change the values from 0 to 100. Then, customize these widgets as you like.

OK, now the Blynk app is ready.

Step 4

Now, let’s creates the program for this project. It is as follows.

/*Temperature monitoring system.
 * http://srituhobby.com
 */
 
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

DHT dht(D3, DHT11); //(sensor pin,sensor type)

char auth[] = ""; //Enter the Auth code which was send by Blink
char ssid[] = "";  //Enter your WIFI Name
char pass[] = "";  //Enter your WIFI Password

BlynkTimer timer;

void sendSensor() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  lcd.setCursor(0, 0);
  lcd.print("Temp : ");
  lcd.print(t);
  lcd.setCursor(0, 1);
  lcd.print("Humi : ");
  lcd.print(h);

  Blynk.virtualWrite(V0, t);
  Blynk.virtualWrite(V1, h);
}
void setup() {

  Wire.begin(D2, D1);
  lcd.init();
  lcd.backlight();
  Blynk.begin(auth, ssid, pass);
  dht.begin();
  timer.setInterval(100L, sendSensor);
}

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

Code Explanation

Firstly, libraries are included.

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>

Secondly, objects are created for these libraries,

LiquidCrystal_I2C lcd(0x27, 16, 2);

DHT dht(D3, DHT11); //(sensor pin,sensor type)

Thirdly, includes the Blynk auth token and WIFI connection details as follows.

char auth[] = "DPOPmn8DiqBjklFYXy0itleC1Szog"; //Enter the Auth code which was send by Blink
char ssid[] = "srituhobby";  //Enter your WIFI Name
char pass[] = "123456";  //Enter your WIFI Password

This is main function of this program,

void sendSensor() {
// Humidity and temperature values are obtained and these values are inserted into float variables
  float h = dht.readHumidity();
  float t = dht.readTemperature();

// The sensor is checked
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

// These values are printed on the LCD
  lcd.setCursor(0, 0);
  lcd.print("Temp : ");
  lcd.print(t);
  lcd.setCursor(0, 1);
  lcd.print("Humi : ");
  lcd.print(h);
// These values are printed on the Blynk app
  Blynk.virtualWrite(V0, t);
  Blynk.virtualWrite(V1, h);
}

In the setup function,

void setup() {

//The wire library is begin

  Wire.begin(D2, D1);

//The I2C library is begin
  lcd.init();

// LCD backlight is turns on
  lcd.backlight();

//The Blynk library is begin using the Blynk auth token and WIFI connections deatails
  Blynk.begin(auth, ssid, pass);

//The DHT11 sensor is begin
  dht.begin();

// This code is called the main function
  timer.setInterval(100L, sendSensor);
}

In the loop function, the Blynk library is run.

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

Step 5

Now, select board and port. After, upload this code to the Nodemcu board.

Lastly, run the Blynk app interface and enjoy this project. The full video guide is given below. So, we will meet in the next tutorial.

How to make a Temperature and Humidity monitoring system using Nodemcu and Blynk

Similar Posts

3 Comments

  1. Hii, i got one problem. Why my LCd screen got no output. Everthing is fine but Output for lcd show nothing “blank”. I hope u can help me with this problem. Sorry. Have a good day

  2. hi ive got problem ” exit status 1
    Error compiling for board NodeMCU 1.0 (ESP-12E Module). ” what should i do?

Leave a Reply

Your email address will not be published.