mpu6050
Simple MPU6050 reader for orange pi and raspberry pi
https://github.com/grizzlei/mpu6050
This program will read gyro and accelerometer sensor data from MPU6050 imu and forward it to serial port, so you can work with the data on your development pc. In main.c
mpu6050 is initialized with ±500 °/s gyro, ±4g accelerometer configurations.
Following format is what you will receive from serial port, which are respectively accelerometer’s x, y, z and gyro’s x, y, z values:
-11224,6704,-88,-84,-99,-7
Quick start with libimu
You can use libimu
(https://github.com/grizzlei/libimu) to process the data you get from sensors. for a quick start, you can compile and use demo.c
on your development pc.
Configuring pi
First, enable i2c-0
and uart-1
interfaces from underlying operating system’s tool. if you have to use a different configuration, update the code accordingly.
For armbian, use armbian-config
Wiring
[mpu6050] -- i2c --> [orange/raspberry pi board] -- uart --> [your development pc]
╔═══════════════╦═══════════════╗
║ orangepi pins ║ mpu6050 pins ║
╠═══════════════╬═══════════════╣
║ 1 [-][a] ║ [a] - vcc ║
║ [b][-] ║ [d] - gnd ║
║ [c][-] ║ [c] - scl ║
║ [-][e] ║ [b] - sda ║
║ [-][f] ║ [-] ║
║ [-][-] ║ [-] ║
║ [-][g] ║ [-] ║
║ [-][-] ║ [-] ║
║ [-][-] ╠═══════════════╣
║ [-][-] ║ usb-ttl pins ║
║ [-][-] ╠═══════════════╣
║ [-][-] ║ [e][f][g][-] ║
║ [d][-] 26 ║ rx tx gnd vcc ║
╚═══════════════╩═══════════════╝
USB-TTL wiring is not necessary if you don’t want gyro and accelerometer sensor data over serial.
Dependencies
apt install libi2c-dev
Build and install
! Program will start as systemd service if you choose to install
git pull https://github.com/grizzlei/mpu6050.git
cd mpu6050
make
(optional) sudo make install
Leave a Reply