Temperature and Humidity Monitoring using Blynk

 Temperature and Humidity Monitoring using Blynk
Temperature and Humidity Monitoring using Blynk

In this tutorial w are going to Monitoring Temperature and Humidity using DHT11 and send the Data to cloud using Blynk

Components Required for this Tutorial :

ESP8266 – 01 WiFi Module

ESP8266-01 WiFi Module
ESP8266-01 WiFi Module

ESP8266-01 is a Serial WiFi Transmitter and Receiver which can give any Micro-controller access to WiFi Network.

ESP8266 module is of low cost and comes pre-programmed with an AT command set firmware, meaning, you can simply hook this up to your Arduino device and get about as much WiFi-ability as a WiFi Shield offers.This module has a powerful on-board processing and storage capability that allows it to be integrated with the sensors and other application through its GPIOs .

Features :

  1. Wi-Fi Direct (P2P), soft-AP
  2. Integrated TCP/IP protocol stack
  3. It features an integrated TR switch, balun, LNA, power amplifier and matching network
  4. Equips integrated PLL, regulators, DCXO and power management units
  5. Integrated low power 32-bit CPU could be used as an application processor
  6. SDIO 1.1 / 2.0, SPI, UART
  7. STBC, 1×1 MIMO, 2×1 MIMO
  8. A-MPDU & A-MSDU aggregation & 0.4ms guard interval
  9. Wake up and transmit packets in < 2ms
  10. Standby power consumption of < 1.0mW (DTIM3)

DHT11 Temperature and Humidity Sensor

DHT11 Temperature and Humidity Sensor
DHT11 Temperature and Humidity Sensor

The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed). Its fairly simple to use, but requires careful timing to grab data.

The only real downside of this sensor is you can only get new data from it once every 2 seconds, so when using our library, sensor readings can be up to 2 seconds old.

TECHNICAL DETAILS

  • Low cost
  • 3 to 5V power and I/O
  • 2.5mA max current use during conversion (while requesting data)
  • Good for 20-80% humidity readings with 5% accuracy
  • Good for 0-50°C temperature readings ±2°C accuracy
  • No more than 1 Hz sampling rate (once every second)
  • Body size 15.5mm x 12mm x 5.5mm
  • 4 pins with 0.1″ spacing

Download Section

Circuit Diagram

Monitoring Temperature and Humidity using Blynk
Circuit Temperature and Humidity Monitoring

The above Circuit Diagram shows the connection between Arduino Nano, ESP-01 and DHT11 Temperature and Humidity Sensor.

You can download the Fritzing File Here

Configuring your ESP8266 – 01 WiFi Module

Connect your ESP 01 in according to the connections given below.

Temperature and Humidity Monitoring using Blynk Configuring ESP8266-01 Wifi Module

Then upload this code to your Arduino Uno.

#include <SoftwareSerial.h>
 
SoftwareSerial mySerial(2,3); //connect esp rx pin to 3
                               //connect esp tx pin to 2
void setup()
{
  Serial.begin(9600);
  while (!Serial)
  {
  }
  mySerial.begin(115200);
  mySerial.println("AT");
  delay(1000);
  mySerial.println("AT+CWMODE=1");
  delay(1000);
  mySerial.println("AT+UART_DEF=9600,8,1,0,0");
}

void loop()
{
  if (mySerial.available())
  {
    Serial.write(mySerial.read());
  }
  if (Serial.available())
  {
    mySerial.write(Serial.read());
  }
}

Now Upload the code and open Serial Monitor. Selectr Both NL & CR and Set baud rate to 9600.

COM Port
COM Port

Try sending the basic command : AT

You must get a OK response. (This means your ESP 01 is working Fine).

Now your ESP 01 will be automatically configured. There are two commands which we have written in the above code.

AT+CWMODE=1 ( Sets the Wi-Fi mode (Station/AP/Station+AP) )

AT+UART_DEF=9600,8,1,0,3 (This will change the baud rate to 9600 you can even set it to 115200.)

Configuration Blynk App

Now let’s setup your Blynk App to receive data of Temperature and Humidity on Graphs.

Steps :

In the widget Box find Gauges, one for Temperature and second for Humidity.

Gauges in Widget Box
Gauges in Widget Box

Setup for Temperature Widget.

Temperature Widget Setup
Temperature Widget Setup

Setup for Humidity Widget.

Setup for Humidity Widget
Setup for Humidity Widget

Now upload the Code and Play.

Code

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SimpleDHT.h>

char auth[] = "Paste Your Authorization Code Here";

char ssid[] = "Paste your WiFi Name Here";
char pass[] = "Paste Your WiFi Password Here";

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&Serial);

const int pinDHT11 = 13; // GPIO2 on your ESP8266 Wifi Module
SimpleDHT11 dht11;

void setup()
{
  Serial.begin(ESP8266_BAUD);
  delay(10);
  //Set ESP8266 baud rate
  // EspSerial.begin(ESP8266_BAUD);
  delay(10);
  Blynk.begin(auth, wifi, ssid, pass);
}

void sendSensor()
{
  // start working...
  Serial.println("=================================");
  Serial.println("Sample DHT11...");

  // read without samples.
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("Read DHT11 failed, err="); Serial.println(err); delay(1000);
    return;
  }
  // for debug purposes.
  Serial.print("Sample OK: ");
  Serial.print((int)temperature); Serial.print(" *C, ");
  Serial.print((int)humidity); Serial.println(" H");
  // DHT11 sampling rate is 1HZ.
  delay(1000);
  Blynk.virtualWrite(V6, temperature);
  Blynk.virtualWrite(V5, humidity);
}

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

Now upload the code and wait for ESP 01 to connect with Blynk and then press the Play button.

Video Tutorial

1+

Leave a Reply

Your e-mail address will not be published. Required fields are marked *