The RHT03 sensor, also known as the DHT22, is a digital temperature and humidity sensor that provides reliable and accurate readings. It is widely used in applications such as environmental monitoring, weather stations, home automation, and HVAC systems due to its ease of use and low cost.
Pin Number | Name | Description |
---|---|---|
1 | VDD | Power supply (3.3 to 6V DC) |
2 | DATA | Digital data output |
3 | NC | Not connected |
4 | GND | Ground |
#include "DHT.h"
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22 // DHT 22 (RHT03)
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();
// Read temperature as Celsius (the default)
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");
}
Q: How often can I request data from the RHT03? A: The RHT03 should not be read more frequently than once every two seconds to ensure accurate measurements.
Q: Can the RHT03 be used outdoors? A: Yes, but it should be protected from direct sunlight and water.
Q: What should I do if the sensor is not responding? A: Double-check the wiring, ensure the correct resistor is in place, and that the power supply is within the specified range. If the issue persists, the sensor may be defective.
For further assistance, please refer to the manufacturer's datasheet and resources.