Crates.io | hmc5883-async |
lib.rs | hmc5883-async |
version | 0.1.3 |
source | src |
created_at | 2022-07-21 08:44:12.104114 |
updated_at | 2022-07-21 08:44:12.104114 |
description | HMC5883 magnetometer async driver for embedded hal |
homepage | |
repository | https://github.com/Dajamante/hmc5983-async |
max_upload_size | |
id | 629538 |
size | 14,019 |
A rust embedded-hal driver for the Honeywell HMC5883. Forked from the original work of Todd Stellanova and made async.
HMC5883 only support a single interface (I2C).
You can connect to the HMC5883 through I2C:
use hmc5883_async::*;
let mut hmc = HMC5883::new(i2c);
hmc.init(&mut Delay).await.expect("init failed");
loop {
if let Ok(temp) = hmc.get_temperature().await {
info!("Temperature: {:?}", temp);
}
match hmc.get_mag_vector().await {
Ok(mag) => info!("Magnitude vector: {:?}", mag),
Err(E) => info!("Printing Error {}", E),
}
Timer::after(Duration::from_secs(3)).await;
}
To run the example:
$ cd examples
$ cargo rb compass