Sensor including resistive humidity sensing component
Fast response, great anti-interference ability and durable
Signal transmission range: 20m
Power: 3.5-5V
Temperature range: 0-50'C
Humidity range: 20-90%RH
cellspacing="1">
style="font-size: 20px;">PINOUT |
---|
PIN |
DESCRIPTION |
1 |
DATA |
2 |
VCC (+5V) |
3 |
GND |
EXAMPLE CODE
ARD_DHT11_HCARDU0020_Example.pde/* FILE: ARD_DHT11_HCARDU0020_Example.pde
style="color: rgb(126, 126, 126);"> DATE: 02/07/12
style="color: rgb(126, 126, 126);"> VERSION: 0.1
style="color: rgb(126, 126, 126);">This is a simple example of how to use the HobbyComponents Arduino DHT11 module
style="color: rgb(126, 126, 126);">(HCARDU0020). The module will work with the Arduino DHT11 library available at
style="color: rgb(126, 126, 126);">http://arduino.cc/playground/Main/DHT11Lib without any modification. This code
style="color: rgb(126, 126, 126);">demonstrates the use of this library to output the current temperature and humidity
style="color: rgb(126, 126, 126);">measured by the sensor.
style="color: rgb(126, 126, 126);">You may copy, alter and reuse this code in any way you like but please leave
style="color: rgb(126, 126, 126);">reference to HobbyComponents.com in your comments if you redistribute this code. */
style="color: rgb(126, 126, 126);">/* Include the DHT11 library available at http://arduino.cc/playground/Main/DHT11Lib */
#include <dht11.h>
dht11 DHT11;
style="color: rgb(126, 126, 126);">/* Define the DIO pin that will be used to communicate with the sensor */
#define DHT11_DIO 2
style="color: rgb(204, 102, 0);">void style="color: rgb(204, 102, 0);">setup()
{
style="color: rgb(126, 126, 126);">/* Setup the serial port for displaying the output of the sensor */
style="color: rgb(204, 102, 0);">Serial.style="color: rgb(204, 102, 0);">begin(9600);
}
style="color: rgb(126, 126, 126);">/* Main program loop */
style="color: rgb(204, 102, 0);">void style="color: rgb(204, 102, 0);">loop()
{
style="color: rgb(126, 126, 126);">/* Perform a read of the sensor and check if data was read OK */
style="color: rgb(204, 102, 0);">if (DHT11.style="color: rgb(204, 102, 0);">read(DHT11_DIO) == DHTLIB_OK)
{
style="color: rgb(126, 126, 126);">/* If so then output the current temperature and humidity to
style="color: rgb(126, 126, 126);"> the serial port */
style="color: rgb(204, 102, 0);">Serial.style="color: rgb(204, 102, 0);">print(style="color: rgb(0, 102, 153);">"Temperature: ");
style="color: rgb(204, 102, 0);">Serial.style="color: rgb(204, 102, 0);">print((style="color: rgb(204, 102, 0);">float)DHT11.temperature, 2);
style="color: rgb(204, 102, 0);">Serial.style="color: rgb(204, 102, 0);">print(style="color: rgb(0, 102, 153);">"oC\t");
style="color: rgb(204, 102, 0);">Serial.style="color: rgb(204, 102, 0);">print(style="color: rgb(0, 102, 153);">"Humidity: ");
style="color: rgb(204, 102, 0);">Serial.style="color: rgb(204, 102, 0);">print((style="color: rgb(204, 102, 0);">float)DHT11.humidity, 2);
style="color: rgb(204, 102, 0);">Serial.style="color: rgb(204, 102, 0);">println(style="color: rgb(0, 102, 153);">"%");
}style="color: rgb(204, 102, 0);">else
{
style="color: rgb(126, 126, 126);">/* If there was a problem reading from then sensor then output
style="color: rgb(126, 126, 126);"> an error */
style="color: rgb(204, 102, 0);">Serial.style="color: rgb(204, 102, 0);">println(style="color: rgb(0, 102, 153);">"ERROR");
}
style="color: rgb(204, 102, 0);">delay(500);
}