Simple test

Ensure your device works with this simple test.

examples/adt7410_simpletest.py
import board
import adafruit_adt7410

i2c = board.I2C()  # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
adt = adafruit_adt7410.ADT7410(i2c, address=0x48)
adt.high_resolution = True

while True:
    print(adt.temperature)
    time.sleep(0.5)

Resolution mode settings

Example showing the Resolution mode setting

examples/adt7410_resolution_mode.py
import time
import board
import adt7410

i2c = board.I2C()
adt = adt7410.ADT7410(i2c)

adt.resolution_mode = adt7410.HIGH_RESOLUTION

while True:
    for resolution_mode in adt7410.resolution_mode_values:
        print("Current Resolution mode setting: ", adt.resolution_mode)
        for _ in range(10):
            temp = adt.temperature
            print("Temperature :{:.2f}C".format(temp))
            time.sleep(0.5)
        adt.resolution_mode = resolution_mode

Temperature Limits

Temperature Limits example

examples/adt7410_temp_limits.py
import board
import adt7410

i2c = board.I2C()  # uses board.SCL and board.SDA
adt = adt7410.ADT7410(i2c)

adt.low_temperature = 18
adt.high_temperature = 29
adt.critical_temperature = 35
adt.hysteresis_temperature = 2

print("High limit: {}C".format(adt.high_temperature))
print("Low limit: {}C".format(adt.low_temperature))
print("Critical limit: {}C".format(adt.critical_temperature))

adt.comparator_mode = adt7410.COMP_ENABLED

while True:
    print("Temperature: {:.2f}C".format(adt.temperature))
    alert_status = adt.alert_status
    if alert_status.high_alert:
        print("Temperature above high set limit!")
    if alert_status.low_alert:
        print("Temperature below low set limit!")
    if alert_status.critical_alert:
        print("Temperature above critical set limit!")
    time.sleep(1)

Operation mode settings

Example showing the Operation mode setting

examples/adt7410_operation_mode.py
import time
import board
import adt7410

i2c = board.I2C()
adt = adt7410.ADT7410(i2c)

adt.operation_mode = adt7410.SPS

while True:
    for operation_mode in adt7410.operation_mode_values:
        print("Current Operation mode setting: ", adt.operation_mode)
        for _ in range(10):
            print("Temperature: {:.2f}C".format(adt.temperature))
            time.sleep(0.5)
        adt.operation_mode = operation_mode