Python module for the SparkFun Qwiic TMP102 Sensor
This python package is a port of the existing SparkFun TMP102 Arduino Examples
This package can be used in conjunction with the overall SparkFun qwiic Python Package
New to qwiic? Take a look at the entire SparkFun qwiic ecosystem.
The qwiic TMP102 Python package current supports the following platforms:
This driver package depends on the qwiic I2C driver: Qwiic_I2C_Py
The SparkFun qwiic TMP102 module documentation is hosted at ReadTheDocs
This repository is hosted on PyPi as the sparkfun-qwiic-tmp102 package. On systems that support PyPi installation via pip, this library is installed using the following commands
For all users (note: the user must have sudo privileges):
sudo pip install sparkfun-qwiic-tmp102
For the current user:
pip install sparkfun-qwiic-tmp102
To install, make sure the setuptools package is installed on the system.
Direct installation at the command line:
python setup.py install
To build a package for use with pip:
python setup.py sdist
A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.
cd dist
pip install sparkfun-qwiic-tmp102-<version>.tar.gz
See the examples directory for more detailed use examples.
from __future__ import print_function
import qwiic_tmp102
import time
import sys
def runExample():
print("\nSparkFun Qwiic TMP102 Sensor Test Example\n")
myTmpSensor = qwiic_tmp102.QwiicTmp102Sensor()
if myTmpSensor.is_connected == False:
print("The Qwiic TMP102 Sensor device isn't connected to the system. Please check your connection", \
file=sys.stderr)
return
myTmpSensor.begin()
print("Initialized.")
while True:
print ("Temp in F: ", myTmpSensor.read_temp_f())
print ("Temp in C: ", myTmpSensor.read_temp_c())
print ("--------------------------------------------")
if __name__ == '__main__':
try:
runExample()
except (KeyboardInterrupt, SystemExit) as exErr:
print("\nEnding Example 1")
sys.exit(0)