icm20x_icm20948_mag_data_rate_test.py
1 # pylint: disable=no-member 2 import time 3 import board 4 import busio 5 from adafruit_icm20x import MagDataRate, ICM20948 6 7 cycles = 200 8 i2c = busio.I2C(board.SCL, board.SDA) 9 icm = ICM20948(i2c) 10 11 # Cycle between two data rates 12 # Best viewed in the Mu serial plotter where you can see how 13 # the data rate affects the resolution of the data 14 while True: 15 icm.magnetometer_data_rate = MagDataRate.RATE_100HZ 16 for i in range(cycles): 17 print(icm.magnetic) 18 time.sleep(0.3) 19 icm.magnetometer_data_rate = MagDataRate.RATE_10HZ 20 for i in range(cycles): 21 print(icm.magnetic) 22 time.sleep(0.3)