adafruit_adt7410

CircuitPython driver for reading temperature from the Analog Devices ADT7410 precision temperature sensor

  • Author(s): ladyada, Jose David M.

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_adt7410.ADT7410(i2c_bus: I2C, address: int = 72)

Interface to the Analog Devices ADT7410 temperature sensor.

Parameters:
  • i2c_bus (I2C) – The I2C bus the ADT7410 is connected to.

  • address (int) – The I2C device address. Default is 0x48

Quickstart: Importing and using the ADT7410 temperature sensor

Here is an example of using the ADT7410 class. First you will need to import the libraries to use the sensor

import board
import adafruit_adt7410

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
adt = adafruit_adt7410.ADT7410(i2c_bus, address=0x48)

Now you have access to the temperature using temperature.

temperature = adt.temperature
property alert_status

The current triggered status of the high and low temperature alerts as a AlertStatus named tuple with attributes for the triggered status of each alert.

import time
import board
import adt7410

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

tmp.low_temperature = 20
tmp.high_temperature = 23
tmp.critical_temperature = 30

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

adt.comparator_mode = adt7410.COMP_ENABLED

while True:
    print("Temperature: {:.2f}C".format(adt.temperature))
    alert_status = tmp.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)
property comparator_mode: str

Sensor comparator_mode

Mode

Value

adt7410.COMP_DISABLED

0b0

adt7410.COMP_ENABLED

0b1

property critical_temperature: float

Critical temperature limit value in Celsius When the temperature goes above the critical_temperature, and if comparator_mode is selected. The alert_status critical_alert clears to 0 when the status register is read and/or when the temperature measured goes back below the limit set in critical_temperature + hysteresis_temperature

The INT pin is activated if a critical over temperature event occur The default setting is 147°C

property high_resolution: bool

Whether the device is currently configured for high resolution mode.

property high_temperature: float

High temperature limit value in Celsius When the temperature goes above the high_temperature, and if comparator_mode is selected. The alert_status high_alert clears to 0 when the status register is read and/or when the temperature measured goes back below the limit set in the setpoint high_temperature + hysteresis_temperature

The INT pin is activated if an over temperature event occur The default setting is 64°C

property hysteresis_temperature: float

Hysteresis temperature limit value in Celsius for the critical_temperature, high_temperature and low_temperature limits

property low_temperature: float

Low temperature limit value in Celsius. When the temperature goes below the low_temperature, and if comparator_mode is selected. The alert_status low_alert clears to 0 when the status register is read and/or when the temperature measured goes back above the limit set in the setpoint low_temperature + hysteresis_temperature

The INT pin is activated if an under temperature event occur The default setting is 10°C

property operation_mode: str

Sensor operation_mode

Continuous Mode

In continuous conversion mode, the read operation provides the most recent converted result.

One Shot Mode

When one-shot mode is enabled, the ADT7410 immediately completes a conversion and then goes into shutdown mode. The one-shot mode is useful when one of the circuit design priorities is to reduce power consumption.

SPS Mode

In this mode, the part performs one measurement per second. A conversion takes only 60 ms, and it remains in the idle state for the remaining 940 ms period

Shutdown Mode

The ADT7410 can be placed in shutdown mode, the entire IC is shut down and no further conversions are initiated until the ADT7410 is taken out of shutdown mode. The conversion result from the last conversion prior to shutdown can still be read from the ADT7410 even when it is in shutdown mode. When the part is taken out of shutdown mode, the internal clock is started and a conversion is initiated

Mode

Value

adt7410.CONTINUOUS

0b00

adt7410.ONE_SHOT

0b01

adt7410.SPS

0b10

adt7410.SHUTDOWN

0b11

property resolution_mode: str

Sensor resolution_mode

Mode

Value

adt7410.LOW_RESOLUTION

0b0

adt7410.HIGH_RESOLUTION

0b1

property temperature: float

Temperature in Celsius In normal mode, the ADT7410 runs an automatic conversion sequence. During this automatic conversion sequence, a conversion takes 240 ms to complete and the ADT7410 is continuously converting. This means that as soon as one temperature conversion is completed, another temperature conversion begins. On power-up, the first conversion is a fast conversion, taking typically 6 ms. Fast conversion temperature accuracy is typically within ±5°C. The measured temperature value is compared with a critical temperature limit, a high temperature limit, and a low temperature limit. If the measured value exceeds these limits, the INT pin is activated; and if it exceeds the critical_temp limit, the CT pin is activated.

class adafruit_adt7410.AlertStatus(high_alert, low_alert, critical_alert)
critical_alert

Alias for field number 2

high_alert

Alias for field number 0

low_alert

Alias for field number 1