mpu-9250/6500 raspberry pi compass code example
Example: mpu-9250/6500 raspberry pi compass
import utime
from machine import I2C, Pin
from mpu9250 import MPU9250
i2c = I2C(scl=Pin(22), sda=Pin(21))
sensor = MPU9250(i2c)
print("MPU9250 id: " + hex(sensor.whoami))
while True:
print(sensor.acceleration)
print(sensor.gyro)
print(sensor.magnetic)
print(sensor.temperature)
utime.sleep_ms(1000)