Ensure your device works with this simple test.
examples/adt7410_simpletest.pyimport 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.pyimport time import adt7410 import board 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(f"Temperature :{temp:.2f}C") time.sleep(0.5) adt.resolution_mode = resolution_modeTemperature Limits
Temperature Limits example
examples/adt7410_temp_limits.pyimport adt7410 import board 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(f"High limit: {adt.high_temperature}C") print(f"Low limit: {adt.low_temperature}C") print(f"Critical limit: {adt.critical_temperature}C") adt.comparator_mode = adt7410.COMP_ENABLED while True: print(f"Temperature: {adt.temperature:.2f}C") 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.pyimport time import adt7410 import board 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(f"Temperature: {adt.temperature:.2f}C") time.sleep(0.5) adt.operation_mode = operation_modeDisplayIO Simpletest
This is a simple test for boards with built-in display.
examples/adt7410_displayio_simpletest.pyimport time import board from adafruit_display_text.bitmap_label import Label from displayio import Group from terminalio import FONT import adafruit_adt7410 # Simple demo of using the built-in display. # create a main_group to hold anything we want to show on the display. main_group = Group() # Initialize I2C bus and sensor. i2c = board.I2C() # uses board.SCL and board.SDA adt = adafruit_adt7410.ADT7410(i2c, address=0x48) adt.high_resolution = True # Create Label(s) to show the readings. If you have a very small # display you may need to change to scale=1. display_output_label = Label(FONT, text="", scale=2) # place the label(s) in the middle of the screen with anchored positioning display_output_label.anchor_point = (0, 0) display_output_label.anchored_position = ( 4, board.DISPLAY.height // 2 - 60, ) # add the label(s) to the main_group main_group.append(display_output_label) # set the main_group as the root_group of the built-in DISPLAY board.DISPLAY.root_group = main_group # begin main loop while True: # update the text of the label(s) to show the sensor readings display_output_label.text = f"Temperature: {adt.temperature:.1f} C" # wait for a bit time.sleep(0.5)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4