aht30
Better AHT10 / AHT20 / AHT30 / AHT40 humidity temperature sensor driver, for rust embedded-hal, optional async.
- Flexable design: configurable I2C address, enable / disable checksum.
- Optional async: enable the
asyncfeature, can be used with embassy. - Friendly for no-FPU platform: allow read raw
u32oru16value. - Correct and sound: follow official datasheet and routine. Already tested on real hardware.
Example
AHT10 async
use ;
use ;
use I2c; // or whatever any embedded-hal i2c, like ch32-hal, stm32f4xx-hal, and linux-embedded-hal
let i2c = new?
.with_sda
.with_scl
.into_async;
let mut aht10 = new;
aht10.calibrate.await?; // do calibrate is recommended
let = aht10.read.await?.decode; // aht10 has no checksum support
// example output: humidity = 67.25 %, temperature = 23.75 °C
info!;
// read raw value without calc decode formula
let humidity_raw = aht10.read.await?.humidity_raw;
AHT10 sync
use ;
use Delay;
use I2c;
let i2c = new?
.with_sda
.with_scl;
let mut aht10 = new;
aht10.calibrate?;
let = aht10.read?.decode;
AHT20 / AHT25 / AHT30, async
For sync usage, see aht10 example. Just remove Async suffix in name.
use ;
let mut aht20 = new;
aht20.calibrate.await?; // do calibrate may not be required for models manufactured after 2022, but still recommended
let = aht20.read.await?.decode; // enable checksum is recommended
AHT40, async
use ; // it has different i2c address
let mut aht40 = new;
// aht40 has no calibrate function
let = aht40.read.await?.decode; // enable checksum is recommended