Crates.io | aht10-embedded |
lib.rs | aht10-embedded |
version | 0.0.2 |
source | src |
created_at | 2023-11-30 23:08:17.092496 |
updated_at | 2024-11-09 12:48:33.565049 |
description | A platform agnostic driver to interface with the AHT10 temperature/humidity sensor, tested on Rasberry Pi Pico |
homepage | https://github.com/jnthbdn/rs-aht10 |
repository | https://github.com/jnthbdn/rs-aht10 |
max_upload_size | |
id | 1054574 |
size | 29,554 |
I haven't found a driver that works simply (without async 😉 ) for an embedded environment and #no_std
.
First, create the AHT10 struct, with your I2C
let mut aht = AHT10::new(i2c1);
Then, initialize the sensor
match aht.initialize() {
Ok(_) => (),
Err(e) => {
// AAAAaarrrgggg.... 😵
}
}
Finally, read the data:
match aht.read_data(&mut delay) {
Ok(data) => {
// Yay ! It works !
let celsius = data.temperature_celsius();
let fahrenheit = data.temperature_fahrenheit(); // 😶
let humidity = data.humidity();
}
Err(e) => {
// AAAAaarrrgggg... 😵
}
};
There is only one example named rp_pico_aht10
. It uses GPIOs 2 & 3 (SDA & SCL respectively) and print data on USB serial port.