Monitor Temperature & Humidity using Blynk 2.0

Table of Contents

Monitoring temperature and humidity is a necessity for various systems. This type of system is widely used in industrial sectors, science laboratories, and nowadays in smart homes also. So, I made a device to Monitor Temperature & Humidity using blynk 2.0 & NodeMCU.

Components required for this project:

You can purchase the Items from here


Node MCU  DHT 11 RGB LED PVC Box  Hot glue gun USB CABLE  


Node MCU DHT 11  RGB LED  PVC Box  Hot glue gun USB CABLE

How DHT 11 sensor works:

Temperature and Humidity Sensor
DHT 11

DHT stands for Digital humidity temperature. The DHT11 is a commonly used temperature and humidity sensor.

The sensor comes with a dedicated NTC thermistor to measure temperature and a humidity Sensor. The humidity sensor consists of 2 electrodes and a moisture-holding substrate in-between. An 8-bit microcontroller is used to output the values of temperature and humidity as serial data. The sensor is also factory calibrated and hence easy to interface with other microcontrollers.

The microcontroller sends a total of 40-bit data for a single reading.

The sensor can measure temperature from 0°C to 50°C and humidity from 20% to 90% with an accuracy of ±1°C and ±1% respectively.

Choosing the microcontroller board:

ESP 8266
Node MCU

I used NodeMCU or ESP8266 as a microcontroller unit. I used this because my project needs internet connectivity and this is the cheapest microcontroller board with Wi-Fi connectivity.


I also used to common cathode RGB LED for showing the status of the temperature and humidity on the device itself.

Circuit Explanation & Making the device

For powering up the device I used a USB female socket (also known as 3500 connectors).

3500 Power connector
3500 Power connector

Circuit diagram

Circuit diagram
circuit diagram

The positive spin of the USB female socket is connected to the Vin pin & the ground pin is connected to the ground pin of NodeMCU.

Vcc and ground pin of the DHT11 sensor are connected to 3.3 v and ground pin of the NodeMCU respectively. The data pin is connected to PIN D5 or GPIO 14.

The common cathode pins of two RGB LEDs are connected to the ground pin of NodeMCU. The red, green, and blue pin of the first RGB led is connected to the D1, D2, and D3 pin of the NodeMCU and for the second RGB LED it is D6, D7, and D8 pin of the NodeMCU.

pvc box

I used a 4″*4″ PVC box as an enclosure of the system. The top panel of the box has nice cut sleet and I used this sleet for mounting the RGB LED.

DHT 11 in the box
DHT 11 in the box

I made a square-shaped slot in the side of the box to mount the DHT11 sensor and I fixed the sensor with the box using hot glue.

Mounting the box
Mounting the box

For mounting the board into the wall I used a half-inch PVC casing which I mounted in the backside of the box using a couple of 3mm nut bolts.

Whole setup from inside
Whole setup from inside

After connecting all the parts I close the top part of the box with some screws.

Blynk Web setup 

First, you have to open this link.

log in to blynk 2.0
log in to blynk 2.0

If you don’t have an account in Blynk. You have to click on Create an account. And then provide your Email address click the Check box and click on Sign up.

After signing up you will get an email to generate your password. Click on Create password. It will redirect you to the blynk page and you have set your password as you like and then click on next.

Enter your Name & click on Done.

After that, the main blynk account page will appear.

For creating a project first you have to click on the Template.

What is Blynk Template?

blynk new template
blynk new template

A template is a project in which we can create a web and mobile dashboard for a specific hardware project in our case that is temperature and humidity monitoring system.

So click on the new template. Enter a template name.

Select the hardware board(ESP 8266).

The connection type will be wifi.

 Then you can add a description of your project.

Click on Done.

Now the template is created.

After that, you can choose a category according to your project. Don’t worry if you are not getting your category in this list you can choose others.

Here are two important things that you should remember one is template id and another one is device name which is required in the time of programming.

In the metadata section, you don’t have to do anything for this project.

In the data stream section, you have to create a data stream.

What is Datastream ?

blynk datastream
blynk datastream

A data stream is like a pipeline or channel. The data will be sent or received through these data channels.

In a single project or template, there can be multiple DataStream. In our project, we are receiving 2 data temp and humidity so in this project we created two DataStream.

Click on the new DataStream. Here are three options virtual pin, Enumerable, or any location. In our case, it is a virtual pin.

Now you have to give a name for every data stream.

After that, you have to choose virtual pins for DataStream. For temperature I choose V1 and for Humidity I choose V2.

I choose the datatype as an integer because DHT 11 doesn’t have floating-point precision.

Set unit for DataStream as per the variable. I choose degree centigrade for temperature & percentage for humidity.

Also, set the minimum and maximum values for the data streams.

Keep the events section the same as it is. It also has some uses. But it is the topic for another article.

Design the Blynk 2.0 Web Dashboard

blynk web dashboard
blynk web dashboard

After that moving on to the web dashboard. In this section, you will be able to see some widgets for making your cool-looking web dashboard.

But all the widgets are not free. You will get it all if you purchase their upgrade plan.

For showing the value of temperature and humidity I will choose two labels you can choose any widget according to your project.

Now change the settings of the label. In settings, you have to give a name to the widget and you have to choose the data stream with which the widget will be connected.

After setting up the widgets click on the save button to save the entire project.

save blynk project
blynk save project

Coding the NodeMCU board

For the code, I use this blynk library and from that library, I used the Blynk Edgent ESP8266 example code with some modifications.

Next, I merged the code of the DHT11 sensor with the blynk edgent code and send the data of the DHT 11 sensor to the blynk cloud after a 2-second iteration with the help of the blynk timer. I also declared the pins for the RGB LEDs and change the color of the RGB LEDs depending upon the temperature & humidity value in the void loop section.

Github Link


#define BLYNK_TEMPLATE_ID "*******"
#define BLYNK_DEVICE_NAME "****"

#define BLYNK_PRINT Serial
#define APP_DEBUG
#define DHTPIN 14 //D5 pin of Node MCU 
#define DHTTYPE DHT11
#define R1 5
#define G1 4
#define B1 0
#define R2 12
#define G2 13
#define B2 15
#define MODE
#include "BlynkEdgent.h"
#include <DHT.h>

int value = 200;

BlynkTimer timer1;
float h , t;

void sendSensor()
 h = dht.readHumidity();
 t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
  Blynk.virtualWrite(V2, h);
  Blynk.virtualWrite(V1, t);

void setup()
  pinMode(R1,OUTPUT); pinMode(G1,OUTPUT); pinMode(B1,OUTPUT);
  pinMode(R2,OUTPUT); pinMode(G2,OUTPUT); pinMode(B2,OUTPUT);
  analogWrite(R1,0); analogWrite(R2,0); 
  analogWrite(G1,0); analogWrite(G2,0); 
  analogWrite(B1, 0); analogWrite(B2, 0);
  timer1.setInterval(2000L, sendSensor);

void loop() 
  h = dht.readHumidity();
  t = dht.readTemperature();
  if (t>0 && t<15)        
    Serial.print("COLD   "); 
    analogWrite(R1,0); analogWrite(G1,0); analogWrite(B1, value); 
  else if (t>14 && t<30)  
    Serial.print("WARM   "); 
    analogWrite(R1,0); analogWrite(G1,value); analogWrite(B1, 0); 
  else if (t>30 && t<45)  
    Serial.print("HOT   "); 
    analogWrite(R1,value); analogWrite(G1,60); analogWrite(B1, 0); 
    Serial.print("VERY HOT  ");
    analogWrite(R1,value); analogWrite(G1,0); analogWrite(B1, 0); 

  if (h>0 && h<30)        
    Serial.println("LOW HUMIDITY"); 
    analogWrite(R2,0); analogWrite(G2,0); analogWrite(B2, value); 
  else if (h>30 && h<50)  
    Serial.println("Normal HUMIDITY"); 
    analogWrite(R2,0); analogWrite(G2,value); analogWrite(B2, 0); 
    Serial.println("HIGH HUMIDITY");
    analogWrite(R2,value); analogWrite(G2,0); analogWrite(B2, 0); 

Blynk Mobile application setup 

Download the blynk application into your mobile.

  1. New Blynk Mobile App (Android)
  2. New Blynk Mobile App (iOS)

After installing the application login into your account. Turn on the developer mode if it is not turned on by going into your profile.

Now turn on your NodeMCU and follow these steps:

Add new device –> Ready –> choose the wifi which is created by the NodeMCU –> give the wifi credentials of the router with which you want to connect the NodeMCU –> Continue –> Now the board will connect to the router if the given wifi credentials are true –> Continue –> Continue –> Done –> OK, great! –> Finish and exit.

Now a box will appear on your screen. Tap on the box –> Click on the spanner icon –> Click on 3 dots –> add the widget according to your need –> Setup the widget by choosing the virtual pins for the widgets.

blynk 2.0 mobile app set up

That is it for the Mobile dashboard setup.

Now you can see the data of your blynk device into your mobile app and in the web dashboard as well.

If you want to see how I made my blynk device then you can watch this video.

blynk 2.0 project

Like it !! Share it !!

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on pinterest

Related Articles