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 NotesHardware:
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
Options for alert_mode
. See alert_mode
for more information.
Create new instance of AlertStatus(high_alert, low_alert)
Alias for field number 0
Alias for field number 1
Options for averaged_measurements
Options for measurement_delay
Options for measurement_mode
. See measurement_mode
for more information.
Library for the TI TMP117 high-accuracy temperature sensor
Sets the behavior of the low_limit
, high_limit
, and alert_status
properties.
When set to AlertMode.WINDOW
, the high_limit
property will unset when the measured temperature goes below high_limit
. Similarly low_limit
will be True or False depending on if the measured temperature is below (False
) or above(True
) low_limit
.
When set to AlertMode.HYSTERESIS
, the high_limit
property will be set to False
when the measured temperature goes below low_limit
. In this mode, the low_limit
property of alert_status
will not be set.
The default is AlertMode.WINDOW
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)
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_delay
Note 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
The high temperature limit in degrees Celsius. When the measured temperature exceeds this value, the high_alert
attribute of the alert_status
property will be True. See the documentation for alert_status
for more information
Configure the sensor with sensible defaults. initialize
is primarily provided to be called after reset
, however it can also be used to easily set the sensor to a known configuration
The low temperature limit in degrees Celsius. When the measured temperature goes below this value, the low_alert
attribute of the alert_status
property will be True. See the documentation for alert_status
for more information
The minimum amount of time between measurements in seconds. Must be a MeasurementDelay
. The specified amount may be exceeded depending on the current setting off averaged_measurements
which determines the minimum time needed between reported measurements.
measurement_mode
must be one of:
Mode
Behavior
MeasurementMode.CONTINUOUS
Measurements are made at the interval determined by
averaged_measurements
and measurement_delay
.
temperature
returns the most recent measurement
MeasurementMode.ONE_SHOT
Take a single measurement with the current number of
averaged_measurements
and switch to SHUTDOWN
when
finished.
temperature
will return the new measurement until
measurement_mode
is set to CONTINUOUS
or ONE_SHOT
is
set again.
MeasurementMode.SHUTDOWN
The sensor is put into a low power state and no new
measurements are taken.
temperature
will return the last measurement until
a new measurement_mode
is selected.
Reset the sensor to its unconfigured power-on state
A 48-bit, factory-set unique identifier for the device.
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 until take_single_measurement()
or temperature
are read.
Note: if averaged_measurements
is 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
The current measured temperature in degrees Celsius
User defined temperature offset to be added to measurements from temperature
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