Wemos Mini and DHT Pro example

In this example we connect the DHT22 Single Bus Digital Temperature Humidity Sensor (DHT Pro shield) to our Wemos Mini , you can see this in the picture below which shows the shield

dht22
dht22

 

Code

There are basic examples , the code below is based on the example from https://github.com/wemos/D1_mini_Examples.git

[codesyntax lang=”cpp”]

#include "DHT.h"
#define DHTPIN D4     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)

DHT dht(DHTPIN, DHTTYPE);

void setup() 
{
  Serial.begin(9600);
  Serial.println("DHTxx test!");
  dht.begin();
}

void loop() 
{
  // Wait a few seconds between measurements.
  delay(2000);

  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) 
  {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print(f);
  Serial.println(" *F");

}

[/codesyntax]

 

Output
Open the serial monitor with Ctrl+Shift M or Tools->Serial Monitor, and you should see the values for the humidity in percent as well as the temperature & heat index in Celcius and Fahrenheit. Here is my hardware running

dht22 wemos
dht22 wemos

 

Links

DHT22 Single Bus Digital Temperature Humidity Sensor Shield For WeMos D1 Mini