Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4""" Display magnetometer data once per second """
5
6import time
7import board
8import adafruit_mmc56x3
9
10i2c = board.I2C() # uses board.SCL and board.SDA
11# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
12sensor = adafruit_mmc56x3.MMC5603(i2c)
13
14while True:
15 mag_x, mag_y, mag_z = sensor.magnetic
16 temp = sensor.temperature
17
18 print(
19 "X:{0:10.2f}, Y:{1:10.2f}, Z:{2:10.2f} uT\tTemp:{3:6.1f}*C".format(
20 mag_x, mag_y, mag_z, temp
21 )
22 )
23 print("")
24 time.sleep(1.0)