Skip to content

MPU6886 driver, embedded-hal 1.0, partially tested on M5Stack Core2

Notifications You must be signed in to change notification settings

hyx0329/mpu6886-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MPU6886 driver

This is a simple MPU6886 driver with embedded-hal 1.0 support.

What's implemented:

  • set/get gyro rate
  • read gyro
  • set/get accelerometer rate
  • read accelerometer
  • read temperature
  • wake
  • sleep
  • enable/disable accel/gyro/temperature
  • use internal 20MHz clock or best clock

MPU6886 also supports i2c address 0x69, use [Mpu6886::new_with_addr] for that.

Example

minimum:

use mpu6886::Mpu6886;

let mut sensor = Mpu6886::new(i2c);
let _ = sensor.wake();
gyro = sensor.gyro().unwrap();
acc = sensor.acceleration().unwrap();

proper:

use mpu6886::{Mpu6886, Error};

let mut sensor = Mpu6886::new(i2c);
match sensor.init() {
    Ok(_) => {},
    Err(e) => match e {
        Error::UnknownChip(chip_id) => panic!("Unknown chip found, ID: {}", chip_id),
        _ => panic!("Communication error!"),
    },
};
let _ = sensor.wake();
gyro = sensor.gyro().unwrap();
acc = sensor.acceleration().unwrap();

About

MPU6886 driver, embedded-hal 1.0, partially tested on M5Stack Core2

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages