1
Fork 0
Find a file
Niklas Cathor 98db8a15c6 Make device address configurable
The i2c address can be changed by pulling the AD0 pin up (Section 6.4,
Page 15 of datasheet revision 3.2).

This can be necessary to do if there is an address conflict with
another chip.
2021-07-14 20:21:00 +02:00
.cargo build example in base cargo.toml with dev-dependencies 2019-05-20 16:20:34 +02:00
.circleci add versions since 1.40 2021-02-15 18:57:41 +01:00
.github Upgrade to GitHub-native Dependabot 2021-04-29 21:04:59 +00:00
examples add example README [skip ci] 2021-02-20 13:27:21 +01:00
misc enable motion detection 2021-02-19 22:58:57 +01:00
src Make device address configurable 2021-07-14 20:21:00 +02:00
.gitignore make sure no target folder can be committed 2019-04-23 11:05:52 +02:00
Cargo.toml bump version to 1.4 2021-02-20 13:24:38 +01:00
LICENSE Update LICENSE 2019-04-16 00:45:44 +02:00
README.md prep for crate version 1.4 2021-02-20 13:13:04 +01:00

mpu6050 crates.io CircleCI

no_std driver for the MPU6050 6-axis IMU

What Works

  • Reading the accelerometer, gyroscope, temperature sensor
    • raw
    • scaled
    • roll/pitch estimation
  • Motion Detection
  • Setting Accel/Gyro Ranges/Sensitivity
  • Setting Accel HPF/LPF

Basic usage

To use this driver you must provide a concrete embedded_hal implementation. Here's a linux_embedded_hal example

use mpu6050::*;
use linux_embedded_hal::{I2cdev, Delay};
use i2cdev::linux::LinuxI2CError;

fn main() -> Result<(), Mpu6050Error<LinuxI2CError>> {
  let i2c = I2cdev::new("/dev/i2c-1")
          .map_err(Mpu6050Error::I2c)?;

  let mut delay = Delay;
  let mut mpu = Mpu6050::new(i2c);

  mpu.init(&mut delay)?;

  loop {
    // get roll and pitch estimate
    let acc = mpu.get_acc_angles()?;
    println!("r/p: {:?}", acc);

    // get temp
    let temp = mpu.get_temp()?;
    println!("temp: {:?}c", temp);

    // get gyro data, scaled with sensitivity 
    let gyro = mpu.get_gyro()?;
    println!("gyro: {:?}", gyro);

    // get accelerometer data, scaled with sensitivity
    let acc = mpu.get_acc()?;
    println!("acc: {:?}", acc);
  }
}