Home » MH ET LIVE ESP32 MINI KIT and Wemos DHT11 shield example

MH ET LIVE ESP32 MINI KIT and Wemos DHT11 shield example

by shedboy71

As promised we said we would try out some of the Wemos Mini shields with the MH ET LIVE ESP32 MINI KIT.  Here is a picture of the DH11 shield.

Each shield comes with a choice of header you can solder if you want, as you will be able to see in the code example later the DHT11 connects to D4, one disadvantage of using a shield is this cannot be changed but for beginners and most people this is not an issue as the benefits of using the shield outweigh any drawbacks

Here you can see the DHT11 shield connected to a MH ET LIVE ESP32 MINI KIT, again the headers I used allow you to stack another shield on top of the DHt11 such as logging shield or an OLED.

 

Code

This example uses the Adafruit libraries

https://github.com/adafruit/DHT-sensor-library

and

https://github.com/adafruit/Adafruit_Sensor

[codesyntax lang=”cpp”]
#include “DHT.h”

#define DHTPIN 16 // what pin we're connected to

// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);

void setup()
{
Serial.begin(9600);
Serial.println(“DHT11 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 and you should see something like this

Humidity: 19.00 % Temperature: 24.00 *C 75.20 *F
Humidity: 18.00 % Temperature: 25.00 *C 77.00 *F
Humidity: 18.00 % Temperature: 25.00 *C 77.00 *F
Humidity: 18.00 % Temperature: 25.00 *C 77.00 *F
Humidity: 18.00 % Temperature: 25.00 *C 77.00 *F
Humidity: 18.00 % Temperature: 25.00 *C 77.00 *F
Humidity: 18.00 % Temperature: 26.00 *C 78.80 *F
Humidity: 18.00 % Temperature: 26.00 *C 78.80 *F

Links

You can pick one of these shields up for about $1.20

DHT Shield for WeMos D1 mini DHT11 Single-bus digital temperature and humidity sensor module sensor

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.