![]() |
| Moduł DHT22 |
Specyfikacja
- napięcie zasilania 3,3 - 6V
- prąd maks. 1,5mA
- interfejs single-bus
- zakres pomiaru wilgotności 0-100%RH
- zakres pomiaru temperatury -40 - 80°C
- dokładność pomiaru
- wilgotności +-2%RH
- temperatury +-0,5°C
- rozdzielczość pomiaru
- wilgotności 0.1%RH
- temperatury 0.1°C
- czas odpowiedzi średnio 2s
Piny
![]() |
| Rozkład pinów identyczny jak w DHT11 (na zdjęciu) |
Schemat połączeń
![]() |
| Identyczny jak dla DHT11 |
Uruchomienie
![]() |
| Uruchomienie DHT22 |
Kod przykładu jest identyczny jak dla DHT11 z wyjątkiem wartości stałej DHTTYPE, którą zmieniłem na DHT22. Sam przykład pochodzi z użytej biblioteki DHT-sensor-library (1).
#include "DHT.h"
#define DHTPIN 2 // what digital pin we're connected to
#define DHTTYPE DHT22 // DHT 22
// Initialize DHT sensor.
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println("DHTxx test!");
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print("Heat index: ");
Serial.print(hic);
Serial.println(" *C ");
}
![]() |
| Dane pomiaru na terminalu |
Źródła:
1) Biblioteka DHT-sensor-library
2) Dokumentacja
3) DHT11, DHT22 and AM2302 Sensors
4) Wide range of Hygrometers: DHT22, AM2302, AM2320, AM2321, SHT71, HTU21D, Si7021, BME280
5) Compare DHT22, DHT11 and Sensirion SHT71





Brak komentarzy:
Prześlij komentarz