Hammad Iqbal
Published © LGPL

IoT Weather Station Using Blynk Application

This tutorial will help you to learn DHT11/DHT22 interfacing with nodeMCU and sending its data to Blynk Application.

IntermediateFull instructions provided1 hour5,662
IoT Weather Station Using Blynk Application

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Story

Read more

Schematics

Connection

Connect DHT signal pin to any GPIO of nodemcu and define same pin in your code.

Code

Code

C/C++
//hammadiqbal12@gmail.com


#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "DHTesp.h"

#ifdef ESP32
#pragma message(THIS EXAMPLE IS FOR ESP8266 ONLY!)
#error Select ESP8266 board.
#endif
int Sensor_PIN  = 0;            //D3

DHTesp dht;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";

float Temperature;
float Humidity;

BlynkTimer timer;

// 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 myTimerEvent()
{
  Temperature = dht.getTemperature(); // Gets the values of the temperature
  Humidity = dht.getHumidity(); // Gets the values of the humidity
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, Temperature);
  Blynk.virtualWrite(V6, Humidity);
}

void setup()
{
  // Debug console
  Serial.begin(9600);
  dht.setup(Sensor_PIN, DHTesp::DHT11);
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

Credits

Hammad Iqbal

Hammad Iqbal

6 projects • 41 followers
I'm an Electrical Engineer and here I'm to share my knowledge about Embedded system.

Comments