mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
.. | ||
.github/workflows | ||
examples | ||
test | ||
.arduino-ci.yml | ||
AM232X.cpp | ||
AM232X.h | ||
keywords.txt | ||
library.json | ||
library.properties | ||
LICENSE | ||
README.md |
AM232X
Arduino library for AM2320 AM2321 and AM2322 I2C temperature and humidity sensor
Description
AM232X is a sensor similar to the DHT12 with an I2C interface. Although in theory this could enable multiple sensors on one bus the AM232X has a fixed address 0x5C so
Typical parameters
range | accuracy | repeatability | |
---|---|---|---|
Temperature | -40 - 80 | 0.5°C | ±0.1 |
Humidity | 0.0 - 99.9 | 3% | ±0.1 |
Sample time | 2 seconds |
// Bottom view
// +---+
// VDD |o |
// SDA |o |
// GND |o |
// SCL |o |
// +---+
Interface
Constructor
- AM232X(TwoWire *wire = &Wire) constructor, optionally set Wire0..WireN.
- bool begin(uint8_t sda, uint8_t scl) for ESP32 alike devices, returns true if device is connected
- bool begin() for AVR alike devices, returns true if device is connected
- bool isConnected() returns true if device-address is found on I2C bus.
Base calls
- int read() fetches the values from the sensor
- float getHumidity() returns the last read humidity
- float getTemperature() returns the last read temperature
Misc
check datasheet for details.
- int getModel() idem
- int getVersion() idem
- uint32_t getDeviceID() idem
- int getStatus()
- int getUserRegisterA()
- int getUserRegisterB()
- int setStatus(uint8_t value)
- int setUserRegisterA(int value)
- int setUserRegisterB(int value)
Operation
See examples
In setup() you have to call the begin() to initialize the Wire library and do an initial read() to fill the variables temperature and humidity. To access these values one must use getTemperature() and getHumidity().
Planned changes
Fix several TODO's in the code.
Warning
The library has several open ends so use at own risk.
See also LICENSE