Rafi Abdurachman
Published © GPL3+

Temp And Humidity Measurement W/ Node MCU, DHT & Blynk

Temp And Humidity Measurement W/ Node MCU, DHT & Blynk

BeginnerShowcase (no instructions)15 minutes15
Temp And Humidity Measurement W/ Node MCU, DHT & Blynk

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Story

Read more

Code

The Code

C/C++
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

char auth[] = "YOURAUTHTOKEN";
char ssid[] = "YOURWIFISSID";
char pass[] = "YOURWIFIPASS";

#define DHTPIN 5          
#define DHTTYPE DHT11    

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

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

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V1, t);
  Blynk.virtualWrite(V2, h);
}

void setup(){
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);

  dht.begin();

  timer.setInterval(1000L, sendSensor);
}

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

Credits

Rafi Abdurachman

Rafi Abdurachman

0 projects • 0 followers

Comments

Add projectSign up / Login