/hmc5883-async

Rust embedded hal no_std driver for HMC5983 and similar magnetometer devices (HMC5883, IST8310)

Primary LanguageRustBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

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