from machine import Pin, I2C
from imu import MPU6050
import time
# Initialize I2C on bus 1 with SDA on pin 20 and SCL on pin 21
i2c = I2C(1, sda=Pin(21), scl=Pin(22), freq=400000)
# Create an MPU6050 object
mpu = MPU6050(i2c)
# Main loop to read and print sensor data
while True:
# Print accelerometer data (x, y, z)
print("-" * 50)
print("x: %s, y: %s, z: %s" % (mpu.accel.x, mpu.accel.y, mpu.accel.z))
time.sleep(0.1)
# Print gyroscope data (x, y, z)
print("X: %s, Y: %s, Z: %s" % (mpu.gyro.x, mpu.gyro.y, mpu.gyro.z))
time.sleep(0.1)
# Print temperature
print("Temperature: %s °C" % mpu.temperature)
time.sleep(0.5)