Crates.io | mpu6050 |
lib.rs | mpu6050 |
version | 0.1.6 |
source | src |
created_at | 2019-04-15 22:46:27.094115 |
updated_at | 2022-11-03 22:14:12.07057 |
description | Platform agnostic driver for MPU6050 6-axis IMU |
homepage | |
repository | https://github.com/juliangaal/mpu6050 |
max_upload_size | |
id | 128235 |
size | 65,413 |
mpu6050
no_std driver for the MPU6050 6-axis IMU
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);
}
}