Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4import time
5import board
6import adafruit_mlx90393
7
8i2c = board.I2C() # uses board.SCL and board.SDA
9SENSOR = adafruit_mlx90393.MLX90393(i2c, gain=adafruit_mlx90393.GAIN_1X)
10
11while True:
12 MX, MY, MZ = SENSOR.magnetic
13 print("[{}]".format(time.monotonic()))
14 print("X: {} uT".format(MX))
15 print("Y: {} uT".format(MY))
16 print("Z: {} uT".format(MZ))
17 # Display the status field if an error occured, etc.
18 if SENSOR.last_status > adafruit_mlx90393.STATUS_OK:
19 SENSOR.display_status()
20 time.sleep(1.0)