API Reference
adafruit_mpu6050
CircuitPython helper library for the MPU6050 6-DoF Accelerometer and Gyroscope.
This driver requires too much RAM to be used on SAMD21 based devices.
Author(s): Bryan Siepert
Implementation Notes
Hardware:
Adafruit MPU-6050 6-DoF Accel and Gyro Sensor (Product ID: 3886)
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
- class adafruit_mpu6050.Bandwidth
Allowed values for
filter_bandwidth.Bandwidth.BAND_260_HZBandwidth.BAND_184_HZBandwidth.BAND_94_HZBandwidth.BAND_44_HZBandwidth.BAND_21_HZBandwidth.BAND_10_HZBandwidth.BAND_5_HZ
- class adafruit_mpu6050.ClockSource
Allowed values for
clock_source.:py:attr:’ClockSource.CLKSEL_INTERNAL_8MHz
:py:attr:’ClockSource.CLKSEL_INTERNAL_X
:py:attr:’ClockSource.CLKSEL_INTERNAL_Y
:py:attr:’ClockSource.CLKSEL_INTERNAL_Z
:py:attr:’ClockSource.CLKSEL_EXTERNAL_32
:py:attr:’ClockSource.CLKSEL_EXTERNAL_19
:py:attr:’ClockSource.CLKSEL_RESERVED
:py:attr:’ClockSource.CLKSEL_STOP
- class adafruit_mpu6050.GyroRange
Allowed values for
gyro_range.GyroRange.RANGE_250_DPSGyroRange.RANGE_500_DPSGyroRange.RANGE_1000_DPSGyroRange.RANGE_2000_DPS
- class adafruit_mpu6050.MPU6050(i2c_bus: I2C, address: int = 104)
Driver for the MPU6050 6-DoF accelerometer and gyroscope.
- Parameters:
Quickstart: Importing and using the device
Here is an example of using the
MPU6050class. First you will need to import the libraries to use the sensorimport board import adafruit_mpu6050
Once this is done you can define your
board.I2Cobject and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA mpu = adafruit_mpu6050.MPU6050(i2c)
Now you have access to the
acceleration,gyroandtemperatureattributesacc_x, acc_y, acc_z = sensor.acceleration gyro_x, gyro_y, gyro_z = sensor.gyro temperature = sensor.temperature
- property cycle: bool
Enable or disable periodic measurement at a rate set by
cycle_rate(). If the sensor was in sleep mode, it will be waken up to cycle
- property filter_bandwidth: int
The bandwidth of the gyroscope Digital Low Pass Filter. Must be a
GyroRange
- read_whole_fifo()
Return raw FIFO bytes
- sample_rate_divisor = 25
The sample rate divisor. See the datasheet for additional detail
- class adafruit_mpu6050.Range
Allowed values for
accelerometer_range.Range.RANGE_2_GRange.RANGE_4_GRange.RANGE_8_GRange.RANGE_16_G
- class adafruit_mpu6050.Rate
Allowed values for
cycle_rate.Rate.CYCLE_1_25_HZRate.CYCLE_5_HZRate.CYCLE_20_HZRate.CYCLE_40_HZ