GY-63_MS5611/libraries/AM232X/README.md

113 lines
3.5 KiB
Markdown
Raw Normal View History

2021-01-29 06:31:58 -05:00
[![Arduino CI](https://github.com/RobTillaart/AM232X/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/AM232X/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/AM232X.svg?maxAge=3600)](https://github.com/RobTillaart/AM232X/releases)
# AM232X
Arduino library for AM2320 AM2321 and AM2322 I2C temperature and humidity sensor
2021-01-29 06:31:58 -05:00
## Description
AM232X is a sensor similar to the DHT12 with an I2C interface.
Although in theory this could enable multiple sensors on one bus
2021-04-07 07:31:22 -04:00
the AM232X has a fixed address **0x5C** so one need to implement a
multiplexing strategy to have multiple sensors in practice.
See multiplexing below.
2021-01-29 06:31:58 -05:00
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
2021-04-07 07:31:22 -04:00
- **bool isConnected(uint16_t timeout = 3000)** returns true if device-address is found on I2C bus. As the device can be in sleep modus it will retry for the defined timeout (in micros) with a minimum of 1 try. minimum = 800 us and maximum = 3000 us according to datasheet.
2021-01-29 06:31:58 -05:00
### 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)**
2021-04-07 07:31:22 -04:00
- **bool wakeUp()** function that will try for 3 milliseconds to wake up the sensor.
2021-01-29 06:31:58 -05:00
## Operation
2021-01-29 06:31:58 -05:00
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.
2021-01-29 06:31:58 -05:00
To access these values one must use **getTemperature()** and **getHumidity()**.
2021-04-07 07:31:22 -04:00
Note that the sensor can go into sleep mode and one might need to call **wakeUp()**
before the **read()**.
## Multiplexing
Multiplexing the AM232X can be done in several ways.
This is not a complete list or tutorial but should get you started.
1. Control the power line by means of an extra pin (+ transistor).
Only switch on the sensor you want to use. Drawback might be time
the sensor takes to boot and to be ready for the first measurement.
2. Use an AND gate between the I2C SCL (clock) line and the I2C SCL
pin of the sensors. This way one can enable / disable communication
per sensor. This will still need an IO pin per sensor but does not
have the "boot time" constraint mentioned above.
3. Use a TCA9548A I2C Multiplexer, or similar.
Which method fit your application depends on your requirements and constraints.
2021-02-03 11:20:20 -05:00
## Future
2021-01-29 06:31:58 -05:00
## Warning
2021-02-03 11:20:20 -05:00
The library has not been tested extensively yet so use at own risk.
2021-01-29 06:31:58 -05:00
See also LICENSE