#=================================================================
# Project : MPU6050 sensor
# Date : 2022-10-15
# Version : 1.0
# Board : Raspberry Pi Pico
#=================================================================
from machine import Pin, I2C
from time import sleep_ms
from mpu6050_lib import mpu6050
#=================================================================
MPU6050_I2C_ADR = 0x68
i2c1 = I2C(1, scl=Pin(7), sda=Pin(6), freq=100000) #100kHz
mpu6050_sensor = mpu6050(i2c1, MPU6050_I2C_ADR, mpu6050.RANGE_4G, mpu6050.RANGE_250_DEG)
while (True):
dict_accel = mpu6050_sensor.read_AccelRegisters()
dict_gyro = mpu6050_sensor.read_GyroRegisters()
print("Accl : x={0:.2f}, y={1:.2f}, z={2:.2f}".format(dict_accel['ax'], dict_accel['ay'],dict_accel['az']))
print("Gyro : x={0:.2f}, y={1:.2f}, z={2:.2f}".format(dict_gyro['gx'], dict_gyro['gy'],dict_gyro['gz']))
utime.sleep_ms(500)