Project – DHT modules with Blynk

Project – DHT modules with Blynk

In this Tutorial we will explain how to make an IoT project. In this project we will be able to read on our smartphone the temperature and humidity sent by a module. So you will learn how to use a DHT modules with blynk! (or DHT11). You can use DHT11/DHT22 or the one that you prefer. Of course you will have to change something in the code if you use a different module!

But no problems! To make it easier for you I will write the line of code that are different using a module or another and I will comment them. Then you only have to choose your module and uncomment the right one for you!

Let’s Start!

What do you need for this project?

  • WeMos board -> if it is your first time with this board you have to follow this guide! Yu have to install the drivers!
  • Temperature module
  • Blynk Account -> you can follow our guide here!


This Schematic is the same for DHT11 and DHT22.

DHT22 schematic

If you have the module with 3 pins, just connect as follows:

  • “-” -> GND
  • “+” -> 5V
  • “out” -> D4

Then we have to make our project on the Blynk app.

Follow this guide to create a New Project on Blynk.

Blynk App

Add two Value Display Widget.

Press on them to edit the Settings and do as in the two pictures.

blynk settings humidity
blynk settings temperature

Now we have to upload our code to the board!


#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#include <DHT.h> 

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "token";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Your WiFi Name";
char pass[] = "Password for WiFi";
#define DHTPIN D4          // What digital pin we're connected to

// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301


BlynkTimer timer;

float t;
float h;

void setup()
  // Debug console
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, sendSensor);
void loop()
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
  h = dht.readHumidity();
  t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
//  l = analogRead(LDR);
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);

Upload the code and when all is done will see on your smartphone the current Temperature and Humidity!

Like in the picture

Humidity and Temperature

Hope you liked doing this project with DHT modules with Blynk. If you have any questions, follow us on instagram and you can write there to me!

Davide Busco

Davide Busco is an engineering student at Federico II University of Naples. He uses his passion and studies to create his projects. He loves be a maker and spread his knowledge. Moreover he has gained the second place in a national makers-tournament between Italian's Universities.

Leave a Reply

Your email address will not be published. Required fields are marked *