Muhammad Fattah Al Fattika
Published

IoT | Connecting and Interfacing a DHT 11 with WeMos D1 Mini

A simple project to learn IoT by connecting a DHT11 temperature and humidity sensor with WeMos D1 Mini and interfacing the data to Blynk.

EasyShowcase (no instructions)1 hour32
IoT | Connecting and Interfacing a DHT 11 with WeMos D1 Mini

Things used in this project

Hardware components

Wemos D1 Mini
Everything ESP Wemos D1 Mini
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Micro-USB to USB Cable (Generic)
Micro-USB to USB Cable (Generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Story

Read more

Schematics

Wiring Diagram

Fattah md0khxaqev

Code

The code

Arduino
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "DHT.h"
#include <SimpleTimer.h> 
#define DHTTYPE DHT11
#define dht_dpin D4
DHT dht(dht_dpin, DHTTYPE); 
SimpleTimer timer;
char auth[] = "Your Auth Code";
char ssid[] = "Your WiFI";
char pass[] = "Your Wifi Password";
float t;
float h;

void setup()
{
    Serial.begin(9600);
    Blynk.begin(auth, ssid, pass);
    dht.begin();
    timer.setInterval(2000, sendUptime);
}

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

void sendUptime()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); 
  Serial.println("Humidity and temperature\n\n");
  Serial.print("Current humidity = ");
  Serial.print(h);
  Serial.print("%  ");
  Serial.print("temperature = ");
  Serial.print(t); 
  Blynk.virtualWrite(V0, t);
  Blynk.virtualWrite(V1, h); 
}

Credits

Muhammad Fattah Al Fattika

Muhammad Fattah Al Fattika

2 projects • 2 followers
Indonesian since 1999

Comments

Add projectSign up / Login