from machine import Pin, I2C
from mpu6050 import MPU6050
import time
# ESP32 Pin assignment
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
mpu = MPU6050(i2c)
# wake up the MPU6050 from sleep
mpu.wake()
# Init current orientation
gyro = mpu.read_gyro_data()
accel = mpu.read_accel_data()
# continuously print the data
while True:
new_gyro = mpu.read_gyro_data()
new_accel = mpu.read_accel_data()
if(new_gyro != gyro or new_accel != accel):
gyro = new_gyro
accel = new_accel
print("Gyro: " + str(gyro) + ", Accel: " + str(accel))
time.sleep(0.1)