Simple test
Ensure your device works with this simple test.
examples/mlx90632_simpletest.py
1# SPDX-FileCopyrightText: Copyright (c) 2025 Liz Clark for Adafruit Industries
2#
3# SPDX-License-Identifier: MIT
4
5"""Simple test example for MLX90632 sensor"""
6
7import time
8
9import board
10
11import adafruit_mlx90632
12
13# Create I2C bus
14i2c = board.I2C() # uses board.SCL and board.SDA
15
16# Create MLX90632 instance
17mlx = adafruit_mlx90632.MLX90632(i2c)
18
19# Print sensor information
20print(f"Product ID: 0x{mlx.product_id:012X}")
21print(f"Product Code: 0x{mlx.product_code:04X}")
22print(f"EEPROM Version: 0x{mlx.eeprom_version:04X}")
23
24# Set measurement mode to continuous
25mlx.mode = adafruit_mlx90632.MODE_CONTINUOUS
26
27# Set refresh rate to 2Hz
28mlx.refresh_rate = adafruit_mlx90632.REFRESH_2HZ
29
30print("\nReading temperatures...")
31
32while True:
33 # Check if new data is available
34 if mlx.data_ready:
35 # Read temperatures
36 ambient_temp = mlx.ambient_temperature
37 object_temp = mlx.object_temperature
38
39 print(f"Ambient: {ambient_temp:.2f}°C, Object: {object_temp:.2f}°C")
40
41 # Reset new data flag
42 mlx.reset_data_ready()
43
44 time.sleep(0.1)