Sensor Library for the AM2302 Sensor (aka DHT22) from ASAIR.
This Library is a controller independent library for reading the AM2302 Sensor also known as DHT22.
One small Docu you will find in the docs folder of this repo.
The actual manufacturer page is linked here: ASAIR AM2302.
The most detailed datasheet you will find here: AM2302 Product Manual
REMARK:
Against the most documentations and datasheets the following Pin description is correct (from left to right):
- Pin1: VDD (3,3...5 V)
- Pin2: SDA (Serial Data, two way)
- Pin3: GND
- PIN4: GND
The library is intended to be used on each microcontroller for Example:
- Arnuino Nano
- Arduino Nano 33 IOT
- ESP8266
- ESP32
- etc ...
Include the library
#include <AM2302-Sensor.h>
The library use namespaces, so the object can be instantiated and used by:
AM2302::AM2302_Sensor am2302{PIN};
void setup() {
am2302.begin();
auto status = am2302.read();
Serial.print("\n\nstatus of sensor read(): ");
Serial.println(AM2302::AM2302_Sensor::get_sensorState(status));
Serial.print("Temperature: ");
Serial.println(am2302.get_Temperature());
Serial.print("Humidity: ");
Serial.println(am2302.get_Humidity());
}
The following status codes exists:
- AM2302_READ_OK {0};
- AM2302_ERROR_CHECKSUM {-1};
- AM2302_ERROR_TIMEOUT {-2};
- AM2302_ERROR_READ_FREQ {-3};
This library is licensed under MIT Licence.