The DHT11 is a widely used digital temperature and humidity sensor that offers a simple interface for measuring ambient temperature and relative humidity. It is a low-cost sensor that is suitable for hobbyist and educational projects, as well as for prototyping and small-scale environmental monitoring applications. The sensor is known for its ease of use and is often interfaced with microcontrollers such as the Arduino UNO.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply (3 to 5.5 VDC) |
2 | DATA | Digital data output |
3 | NC | Not connected (no function) |
4 | GND | Ground |
Connecting the Sensor:
Programming the Arduino:
DHT.h
library in your Arduino sketch. (Install via the Library Manager if not already installed.)DHT
class and specifying the data pin and sensor type (DHT11
).setup()
function, begin communication with the sensor using the begin()
method.loop()
function, read the temperature and humidity using the readHumidity()
and readTemperature()
methods.#include <DHT.h>
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Compute heat index in Celsius (isFahrenheit = false)
float heatIndex = dht.computeHeatIndex(temperature, humidity, false);
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print("% Temperature: ");
Serial.print(temperature);
Serial.print("°C Heat index: ");
Serial.print(heatIndex);
Serial.println("°C");
}
Serial.print()
function to debug and check the values being read from the sensor.Q: Can the DHT11 sensor measure temperature below 0°C or above 50°C? A: No, the DHT11 is limited to a temperature range of 0 to 50°C.
Q: How long should I wait between readings? A: The DHT11 requires a minimum of 1 second between readings for accurate data.
Q: Can I use the DHT11 sensor outdoors? A: The DHT11 can be used outdoors but should be protected from direct sunlight, rain, and condensation.
Q: Is calibration required for the DHT11 sensor? A: The DHT11 comes pre-calibrated from the factory, and no additional calibration is typically required.
Note: The manufacturer part ID "idk" is not a valid identifier. Please provide the correct part ID for more specific information related to the component from the manufacturer. The manufacturer "Arduino" is typically associated with microcontroller boards rather than sensor manufacturing. The DHT11 sensor is produced by various manufacturers and is not an Arduino-specific product.