Simple test¶
Ensure your device works with this simple test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | """
A simple test of the MPU6050 6D0F sensor
"""
# pylint: disable=invalid-name
import time
import board
from circuitpython_mpu6050 import MPU6050
I2C_BUS = board.I2C()
sensor = MPU6050(I2C_BUS)
while True:
try:
accel_x, accel_y, accel_z = sensor.acceleration
temp = sensor.temperature
gyro_x, gyro_y, gyro_z = sensor.gyro
print('temp =', temp)
print('accel =', accel_x, accel_y, accel_z)
print('gyro =', gyro_x, gyro_y, gyro_z)
time.sleep(2)
except KeyboardInterrupt:
del sensor
break
|