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