import machine
import time
from mpu6050 import MPU6050
import ssd1306
# Configurar I2C (SDA=GPIO0, SCL=GPIO1)
i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0), freq=400000)
# Inicializar sensores
mpu = MPU6050(i2c)
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
while True:
accel = mpu.get_accel()
gyro = mpu.get_gyro()
temp = mpu.get_temp()
# Mostrar en consola
print("Acelerómetro (g):", accel)
print("Giroscopio (°/s):", gyro)
print("Temperatura (°C):", temp)
print("----------------------")
# Mostrar en pantalla OLED
oled.fill(0)
oled.text("Temp: {:.1f}C".format(temp), 0, 0)
oled.text("Ax:{:.1f} Ay:{:.1f}".format(accel[0], accel[1]), 0, 16)
oled.text("Gz:{:.1f}".format(gyro[2]), 0, 32)
oled.show()
time.sleep(1)