1 unstable release

0.1.3 Jul 21, 2022

#19 in #magnetometer

BSD-3-Clause

12KB
198 lines

HMC5883 async driver

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).

Example

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

Dependencies

~0.6–1.2MB
~26K SLoC