The DHT Shield is a digital temperature and humidity sensor utilising the DHT11 sensor. Temperature range is 0~60C (+/-2C) and the humidity range is 20-90%RH (+/-5%RH).
WeMos note: The temperature and humidity data read from the sensor is the result of the last measurement (the sensor will make a new measurement after data is read from the sensor). To get real-time data, you need to read twice. It is not recommended to repeatedly read from the sensor, reading interval should be more than 2 seconds to ensure accurate measurements.
Connection
D4 on the D1 mini should be connected to Data Out pin on the DHT module.
Features:
Temperature: 0~60°C (±2°C)
Humidity: 20-90%RH (±5%RH)
Example Arduino Sketch:
Code: Select all
/* WeMos relay example - HobbyComponents.com
WeMos compatible DHT library can be downloaded from our support forum here:
http://forum.hobbycomponents.com/viewtopic.php?f=111&t=2130 */
#include <dht.h>
dht DHT;
/* Define the DIO pin that will be used to communicate with the sensor */
#define DHT11_DIO D4
void setup()
{
/* Setup the serial port for displaying the output of the sensor */
Serial.begin(115200);
}
/* Main program loop */
void loop()
{
/* Perform a read of the sensor and check if data was read OK */
if (DHT.read11(DHT11_DIO) == DHTLIB_OK)
{
/* If so then output the current temperature and humidity to
the serial port */
Serial.print("Temperature: ");
Serial.print((float)DHT.temperature, 2);
Serial.print("oC\t");
Serial.print("Humidity: ");
Serial.print((float)DHT.humidity, 2);
Serial.println("%");
}else
{
/* If there was a problem reading from then sensor then output
an error */
Serial.println("ERROR");
}
/* Wait at least 2 seconds before reading a new temperature */
delay(2000);
}
DHT Arduino library modified for WeMos / ESP8266. Original library available from http://playground.arduino.cc//Main/DHTLib
Schematic: Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do no provide any guarantees or warranties as to their accuracy or fitness for purpose.
Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.