User Manual
require enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different,
and Linux changes often, please visit the CircuitPython on Linux guide to get your computer
ready (https://adafru.it/BSN)!
Once that's done, from your command line run the following command:
sudo pip3 install adafruit-circuitpython-mpu6050
If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use
CircuitPython on Python 2.x, it isn't supported!
CircuitPython & Python Usage
To demonstrate the usage of the sensor we'll initialize it and read the acceleration, rotation, and temperature
measurements from the board's Python REPL.
Run the following code to import the necessary modules and initialize the I2C connection with the sensor:
import time
import board
import busio
import adafruit_mpu6050
i2c = busio.I2C(board.SCL, board.SDA)
mpu = adafruit_mpu6050.MPU6050(i2c)
Now you're ready to read values from the sensor using these properties:
acceleration - The acceleration forces in the X, Y, and Z axes in m/s
gyro - The rotation measurement on the X, Y, and Z axes in degrees/sec
temperature - The temperature of the sensor in degrees C
For example, to print out the acceleration, gyro, and temperature values:
That's all there is to it! Go forth and imbue your robot friends with the gift of being able to maybe not fall down all the
time. Maybe.
Example Code
Temporarily unable to load content:
2
© Adafruit Industries https://learn.adafruit.com/mpu6050-6-dof-accelerometer-and-gyro Page 15 of 20