Introduction
The MPU-6050 is the world’s first and only 6-axis motion tracking devices designed for the low power, low cost, and high performance requirements of smartphones, tablets and wearable sensors.
Required Components
– 1 * Raspberry Pi
– 1 * Breadboard
– 1 * MPU-6050 module
– Several Jumper wires
Experimental Principle
In this experiment, use I2C to obtain the values of the three-axis acceleration sensor and three-axis gyroscope for MPU6050 and display them on the screen.
Experimental Procedures
Step 1: Build the circuit.
Raspberry Pi | GPIO Extension Board | MPU-6050 Module |
SCL | SCL1 | SCL |
SDA | SDA1 | SDA |
3.3V | 3V3 | VCC |
GND | GND | GND |
Step 2: Setup I2C (see Appendix. If you have set I2C, skip this step.)
For C Users:
Step 3: Change directory.
cd /home/pi/SunFounder_SensorKit_for_RPi2/C/32_mpu6050/
Step 4: Compile.
gcc 32_mpu6050.c -lwiringPi -lm
Step 5: Run.
sudo ./a.out
For Python Users:
Step 3: Change directory.
cd /home/pi/SunFounder_SensorKit_for_RPi2/Python/
Step 4: Run.
sudo python3 32_mpu6050.py
Now you can see the values of the acceleration sensor, gyroscope, and XY-axis rotation read by MPU6050 printed on the screen constantly.