adafruit_tmp117¶
CircuitPython library for the TI TMP117 Temperature sensor
Author(s): Bryan Siepert, Ian Grant
parts based on SparkFun_TMP117_Arduino_Library by Madison Chodikov @ SparkFun Electronics: https://github.com/sparkfunX/Qwiic_TMP117 https://github.com/sparkfun/SparkFun_TMP117_Arduino_Library
Serial number register information: https://e2e.ti.com/support/sensors/f/1023/t/815716?TMP117-Reading-Serial-Number-from-EEPROM
Implementation Notes¶
Hardware:
Adafruit TMP117 ±0.1°C High Accuracy I2C Temperature Sensor (Product ID: 4821)
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
- class adafruit_tmp117.AlertMode¶
Options for
alert_mode. Seealert_modefor more information.
- class adafruit_tmp117.AlertStatus(high_alert, low_alert)¶
Create new instance of AlertStatus(high_alert, low_alert)
- property high_alert¶
Alias for field number 0
- property low_alert¶
Alias for field number 1
- class adafruit_tmp117.AverageCount¶
Options for
averaged_measurements
- class adafruit_tmp117.MeasurementDelay¶
Options for
measurement_delay
- class adafruit_tmp117.MeasurementMode¶
Options for
measurement_mode. Seemeasurement_modefor more information.
- class adafruit_tmp117.TMP117(i2c_bus, address=72)¶
Library for the TI TMP117 high-accuracy temperature sensor
- property alert_mode¶
Sets the behavior of the
low_limit,high_limit, andalert_statusproperties.When set to
AlertMode.WINDOW, thehigh_limitproperty will unset when the measured temperature goes belowhigh_limit. Similarlylow_limitwill be True or False depending on if the measured temperature is below (False) or above(True)low_limit.When set to
AlertMode.HYSTERESIS, thehigh_limitproperty will be set toFalsewhen the measured temperature goes belowlow_limit. In this mode, thelow_limitproperty ofalert_statuswill not be set.The default is
AlertMode.WINDOW
- 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 board import adafruit_tmp117 i2c = board.I2C() # uses board.SCL and board.SDA tmp117 = adafruit_tmp117.TMP117(i2c) tmp117.high_limit = 25 tmp117.low_limit = 10 print("High limit", tmp117.high_limit) print("Low limit", tmp117.low_limit) # Try changing `alert_mode` to see how it modifies the behavior of the alerts. # tmp117.alert_mode = AlertMode.WINDOW #default # tmp117.alert_mode = AlertMode.HYSTERESIS print("Alert mode:", AlertMode.string[tmp117.alert_mode]) print("") print("") while True: print("Temperature: %.2f degrees C" % tmp117.temperature) alert_status = tmp117.alert_status print("High alert:", alert_status.high_alert) print("Low alert:", alert_status.low_alert) print("") time.sleep(1)
- property averaged_measurements¶
The number of measurements that are taken and averaged before updating the temperature measurement register. A larger number will reduce measurement noise but may also affect the rate at which measurements are updated, depending on the value of
measurement_delayNote that each averaged measurement takes 15.5ms which means that larger numbers of averaged measurements may make the delay between new reported measurements to exceed the delay set by
measurement_delay
- property high_limit¶
The high temperature limit in degrees Celsius. When the measured temperature exceeds this value, the
high_alertattribute of thealert_statusproperty will be True. See the documentation foralert_statusfor more information
- initialize()¶
Configure the sensor with sensible defaults.
initializeis primarily provided to be called afterreset, however it can also be used to easily set the sensor to a known configuration
- property low_limit¶
The low temperature limit in degrees Celsius. When the measured temperature goes below this value, the
low_alertattribute of thealert_statusproperty will be True. See the documentation foralert_statusfor more information
- property measurement_delay¶
The minimum amount of time between measurements in seconds. Must be a
MeasurementDelay. The specified amount may be exceeded depending on the current setting offaveraged_measurementswhich determines the minimum time needed between reported measurements.
- property measurement_mode¶
- Sets the measurement mode, specifying the behavior of how often measurements are taken.
measurement_modemust be one of:
Mode
Behavior
MeasurementMode.CONTINUOUSMeasurements are made at the interval determined by
averaged_measurementsandmeasurement_delay.temperaturereturns the most recent measurementMeasurementMode.ONE_SHOTTake a single measurement with the current number of
averaged_measurementsand switch toSHUTDOWNwhenfinished.
temperaturewill return the new measurement untilmeasurement_modeis set toCONTINUOUSorONE_SHOTisset again.
MeasurementMode.SHUTDOWNThe sensor is put into a low power state and no new
measurements are taken.
temperaturewill return the last measurement untila new
measurement_modeis selected.
- reset()¶
Reset the sensor to its unconfigured power-on state
- property serial_number¶
A 48-bit, factory-set unique identifier for the device.
- take_single_measurememt()¶
Perform a single measurement cycle respecting the value of
averaged_measurements, returning the measurement once complete. Once finished the sensor is placed into a low power state untiltake_single_measurement()ortemperatureare read.Note: if
averaged_measurementsis set to a high value there will be a notable delay before the temperature measurement is returned while the sensor takes the required number of measurements
- property temperature¶
The current measured temperature in degrees Celsius
- property temperature_offset¶
User defined temperature offset to be added to measurements from
temperature