lis3mdl_simpletest.py
1 """ Display magnetometer data once per second """ 2 3 import time 4 import board 5 import busio 6 import adafruit_lis3mdl 7 8 i2c = busio.I2C(board.SCL, board.SDA) 9 sensor = adafruit_lis3mdl.LIS3MDL(i2c) 10 11 while True: 12 mag_x, mag_y, mag_z = sensor.magnetic 13 14 print("X:{0:10.2f}, Y:{1:10.2f}, Z:{2:10.2f} uT".format(mag_x, mag_y, mag_z)) 15 print("") 16 time.sleep(1.0)