from imu import MPU6050
import time
from machine import Pin, I2C
i2c = I2C(0, sda=Pin(8), scl=Pin(9), freq=400000)
imu = MPU6050(i2c)
def get_temperature():
print("Temperature: ", round(imu.temperature, 2)+1.53, "°C")
while True:
acceleration = imu.accel
gyrometre = imu.gyro
print ("Acceleration x: ", round(acceleration.x,2), " y:", round(acceleration.y,2),
"z: ", round(acceleration.z,2))
print ("gyrometre x: ", round(gyrometre.x,2), " y:", round(gyrometre.y,2),
"z: ", round(gyrometre.z,2))
if abs(acceleration.x) > 0.8:
if (acceleration.x > 0):
print("L'axe x pointe vers le haut")
else:
print("L'axe x pointe vers le bas")
if abs(acceleration.y) > 0.8:
if (acceleration.y > 0):
print("L'axe y pointe vers le haut")
else:
print("L'axe y pointe vers le bas")
if abs(acceleration.z) > 0.8:
if (acceleration.z > 0):
print("L'axe z pointe vers le haut")
else:
print("L'axe z pointe vers le bas")
if abs(gyrometre.x) > 20:
print("Rotation autour de l'axe x")
if abs(gyrometre.y) > 20:
print("Rotation autour de l'axe y")
if abs(gyrometre.z) > 20:
print("Rotation autour de l'axe z")
time.sleep(1)