A python module for the TMP119 digital temperature sensor
Project description
tmp119-python
A Python module to interface with the TMP119 temperature sensor. The TMP119 is an ultra-high-accuracy, low-power digital temperature sensor from Texas Instruments with an I2C-compatible interface. Tested on Raspberry Pi with Raspberry Pi OS.
The python SMBus library must be installed.
sudo apt-get install python3-smbus
Usage
import tmp119
TMP119(bus=1, address=0x48)
sensor = tmp119.TMP119() # Use default I2C bus 1, address 0x48
sensor = tmp119.TMP119(0) # Specify I2C bus 0
sensor = tmp119.TMP119(1, 0x49) # Specify bus and I2C address
The TMP119 supports up to four I2C addresses, selected by the ADD0 pin:
0x48 (ADD0 to GND, default)
0x49 (ADD0 to V+)
0x4A (ADD0 to SDA)
0x4B (ADD0 to SCL)
init()
Initialize the sensor. This needs to be called before using any other methods.
It verifies the device ID and configures the sensor for the fastest update rate
(no averaging, no added standby delay, ~15.5 ms cycle). Call set_averaging() /
set_read_delay() afterwards to trade speed for lower noise.
sensor.init()
Returns True if the sensor was successfully initialized, False otherwise.
read()
Read the sensor and update the temperature. The TMP119 runs in continuous-conversion mode, so this always returns the latest result.
sensor.read()
Returns True if the read was successful, False otherwise.
temperature(conversion=UNITS_Centigrade)
Get the most recent temperature measurement.
sensor.temperature() # Centigrade (default)
sensor.temperature(tmp119.UNITS_Fahrenheit) # Fahrenheit
Valid arguments are:
tmp119.UNITS_Centigrade
tmp119.UNITS_Fahrenheit
tmp119.UNITS_Kelvin
Returns the most recent temperature in the requested units, or temperature in
degrees Centigrade if invalid units specified. Call read() to update.
set_averaging(avg)
Set the conversion averaging mode. More averaging reduces noise but takes longer to produce each result. Returns True if the write succeeded.
sensor.set_averaging(tmp119.TMP119_AVERAGE_64X)
Valid arguments are (with the time each takes per result):
tmp119.TMP119_AVERAGE_1X # 15.5 ms
tmp119.TMP119_AVERAGE_8X # 125 ms
tmp119.TMP119_AVERAGE_32X # 500 ms
tmp119.TMP119_AVERAGE_64X # 1 s
set_read_delay(delay)
Set the minimum standby delay between conversions in continuous-conversion
mode. The actual time between readings is the greater of this standby delay and
the averaging time (see datasheet Table 8-6); for example, TMP119_AVERAGE_64X
always yields at least a ~1 s cycle because the averaging alone takes 1 s,
regardless of the delay setting. Returns True if the write succeeded.
sensor.set_read_delay(tmp119.TMP119_DELAY_1000_MS)
Valid arguments are:
tmp119.TMP119_DELAY_NONE
tmp119.TMP119_DELAY_125_MS
tmp119.TMP119_DELAY_250_MS
tmp119.TMP119_DELAY_500_MS
tmp119.TMP119_DELAY_1000_MS
tmp119.TMP119_DELAY_4000_MS
tmp119.TMP119_DELAY_8000_MS
tmp119.TMP119_DELAY_16000_MS
get_config() / set_config(config)
Read or write the raw 16-bit configuration register (address 0x01) for advanced
use. set_config() returns True if the write succeeded; read-only bits are
ignored by the device.
config = sensor.get_config()
sensor.set_config(config)
Reference
You can find the TMP119 datasheet here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bluerobotics_tmp119-0.0.1.tar.gz.
File metadata
- Download URL: bluerobotics_tmp119-0.0.1.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61da4c2e724ac9c2c6c60b34947cba022b5486cef171110894befa3c8ce9f4e2
|
|
| MD5 |
21045a3b7ec0903b82312faca215615e
|
|
| BLAKE2b-256 |
74a791366d90d082720d8e303b2ed2b379afb1a28accc07cb04d1565de77c465
|
Provenance
The following attestation bundles were made for bluerobotics_tmp119-0.0.1.tar.gz:
Publisher:
deploy_to_pypi.yml on bluerobotics/tmp119-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bluerobotics_tmp119-0.0.1.tar.gz -
Subject digest:
61da4c2e724ac9c2c6c60b34947cba022b5486cef171110894befa3c8ce9f4e2 - Sigstore transparency entry: 1805823773
- Sigstore integration time:
-
Permalink:
bluerobotics/tmp119-python@88ee4864c75506eff45a582e1593f00d3c1f9103 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/bluerobotics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy_to_pypi.yml@88ee4864c75506eff45a582e1593f00d3c1f9103 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bluerobotics_tmp119-0.0.1-py3-none-any.whl.
File metadata
- Download URL: bluerobotics_tmp119-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df10e428baa37f9861e69000c2013a71f50d8b5b3f8c6d172f619185163d37b8
|
|
| MD5 |
dd25310f9b737b64406a00d2d8c7541e
|
|
| BLAKE2b-256 |
47fee4fec1410c4079e4704e0a5606c9ea6e6800392dcef7daf030214b22703b
|
Provenance
The following attestation bundles were made for bluerobotics_tmp119-0.0.1-py3-none-any.whl:
Publisher:
deploy_to_pypi.yml on bluerobotics/tmp119-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bluerobotics_tmp119-0.0.1-py3-none-any.whl -
Subject digest:
df10e428baa37f9861e69000c2013a71f50d8b5b3f8c6d172f619185163d37b8 - Sigstore transparency entry: 1805823804
- Sigstore integration time:
-
Permalink:
bluerobotics/tmp119-python@88ee4864c75506eff45a582e1593f00d3c1f9103 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/bluerobotics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy_to_pypi.yml@88ee4864c75506eff45a582e1593f00d3c1f9103 -
Trigger Event:
push
-
Statement type: