Skip to content

Commit 025d66c

Browse files
Autogenerated. Convert PyPi packaging and add Readme Updates
1 parent b1f747b commit 025d66c

File tree

7 files changed

+185
-170
lines changed

7 files changed

+185
-170
lines changed

README.md

Lines changed: 112 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,125 @@
1-
Qwiic_TMP102_Py
2-
===============
1+
![Qwiic TMP102 - Python Package](docs/images/gh-banner.png "qwiic TMP102 Python Package")
32

4-
<p align="center">
5-
<img src="https://cdn.sparkfun.com/assets/custom_pages/2/7/2/qwiic-logo-registered.jpg" width=200>
6-
<img src="https://www.python.org/static/community_logos/python-logo-master-v3-TM.png" width=240>
7-
</p>
8-
<p align="center">
9-
<a href="https://pypi.org/project/sparkfun-qwiic-tmp102/" alt="Package">
10-
<img src="https://img.shields.io/pypi/pyversions/sparkfun-qwiic_tmp102.svg" /></a>
11-
<a href="https://github.com/sparkfun/Qwiic_TMP102_Py/issues" alt="Issues">
12-
<img src="https://img.shields.io/github/issues/sparkfun/Qwiic_TMP102_Py.svg" /></a>
13-
<a href="https://qwiic-tmp102-py.readthedocs.io/en/latest/?" alt="Documentation">
14-
<img src="https://readthedocs.org/projects/qwiic-tmp102-py/badge/?version=latest&style=flat" /></a>
15-
<a href="https://github.com/sparkfun/Qwiic_TMP102_Py/blob/master/LICENSE" alt="License">
16-
<img src="https://img.shields.io/badge/license-MIT-blue.svg" /></a>
17-
<a href="https://twitter.com/intent/follow?screen_name=sparkfun">
18-
<img src="https://img.shields.io/twitter/follow/sparkfun.svg?style=social&logo=twitter"
19-
alt="follow on Twitter"></a>
3+
# SparkFun Qwiic TMP102 - Python Package
204

21-
</p>
5+
![PyPi Version](https://img.shields.io/pypi/v/sparkfun_qwiic_tmp102)
6+
![GitHub issues](https://img.shields.io/github/issues/sparkfun/qwiic_tmp102_py)
7+
![License](https://img.shields.io/github/license/sparkfun/qwiic_tmp102_py)
8+
![X](https://img.shields.io/twitter/follow/sparkfun)
9+
[![API](https://img.shields.io/badge/API%20Reference-blue)](https://docs.sparkfun.com/qwiic_tmp102_py/classqwiic__tmp102_1_1_qwiic_tmp102_sensor.html)
2210

23-
<img src="https://cdn.sparkfun.com/assets/parts/1/5/0/0/7/16304-SparkFun_Digital_Temperature_Sensor_-_TMP102__Qwiic_-01.jpg" align="right" width=300 alt="SparkFun Qwiic TMP102">
11+
The SparkFun Qwiic Digital Temperature Sensing TMP102 Module provides a simple and cost effective solution for adding Digital Temperature Sensing capabilities to your project. Implementing a SparkFun Qwiic I2C interface, these sensors can be rapidly added to any project with boards that are part of the SparkFun Qwiic ecosystem.
2412

13+
This repository implements a Python package for the SparkFun Qwiic TMP102. This package works with Python, MicroPython and CircuitPython.
2514

26-
Python module for the [SparkFun Qwiic TMP102 Sensor](https://www.sparkfun.com/products/16304)
15+
### Contents
2716

28-
This python package is a port of the existing [SparkFun TMP102 Arduino Examples](https://github.com/sparkfun/SparkFun_TMP102_Arduino_Library/tree/master/examples)
17+
* [About](#about-the-package)
18+
* [Getting Started](#getting-started)
19+
* [Installation](#installation)
20+
* [Supported Platforms](#supported-platforms)
21+
* [Documentation](https://docs.sparkfun.com/qwiic_tmp102_py/classqwiic__tmp102_1_1_qwiic_tmp102_sensor.html)
22+
* [Examples](#examples)
2923

30-
This package can be used in conjunction with the overall [SparkFun qwiic Python Package](https://github.com/sparkfun/Qwiic_Py)
24+
## About the Package
25+
26+
This python package enables the user to access the features of the TMP102 via a single Qwiic cable. This includes <reading temperature, setting alerts> and more. The capabilities of the TMP102 are each demonstrated in the included examples.
3127

3228
New to qwiic? Take a look at the entire [SparkFun qwiic ecosystem](https://www.sparkfun.com/qwiic).
3329

34-
## Contents
30+
### Supported SparkFun Products
3531

36-
* [Supported Platforms](#supported-platforms)
37-
* [Dependencies](#dependencies)
38-
* [Installation](#installation)
39-
* [Documentation](#documentation)
40-
* [Example Use](#example-use)
32+
This Python package supports the following SparkFun qwiic products on Python, MicroPython and Circuit python.
33+
34+
* [SparkFun Digital Temperature Sensing Sensor - TMP102](https://www.sparkfun.com/products/16304)
35+
36+
### Supported Platforms
37+
38+
| Python | Platform | Boards |
39+
|--|--|--|
40+
| Python | Linux | [Raspberry Pi](https://www.sparkfun.com/raspberry-pi-5-8gb.html) , [NVIDIA Jetson Orin Nano](https://www.sparkfun.com/nvidia-jetson-orin-nano-developer-kit.html) via the [SparkFun Qwiic SHIM](https://www.sparkfun.com/sparkfun-qwiic-shim-for-raspberry-pi.html) |
41+
| MicroPython | Raspberry Pi - RP2, ESP32 | [SparkFun RP2040 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-rp2040.html), [SparkFun RP2350 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-rp2350.html), [SparkFun ESP32 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-esp32-wroom-usb-c.html)
42+
|CircuitPython | Raspberry Pi - RP2, ESP32 | [SparkFun RP2040 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-rp2040.html), [SparkFun RP2350 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-rp2350.html), [SparkFun ESP32 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-esp32-wroom-usb-c.html)
43+
44+
> [!NOTE]
45+
> The listed supported platforms and boards are the primary platform targets tested. It is fully expected that this package will work across a wide variety of Python enabled systems.
46+
47+
## Installation
48+
49+
The first step to using this package is installing it on your system. The install method depends on the python platform. The following sections outline installation on Python, MicroPython and CircuitPython.
50+
51+
### Python
4152

42-
Supported Platforms
43-
--------------------
44-
The qwiic TMP102 Python package current supports the following platforms:
45-
* [Raspberry Pi](https://www.sparkfun.com/search/results?term=raspberry+pi)
46-
* [NVidia Jetson Nano](https://www.sparkfun.com/products/15297)
47-
* [Google Coral Development Board](https://www.sparkfun.com/products/15318)
53+
#### PyPi Installation
4854

49-
Dependencies
50-
--------------
51-
This driver package depends on the qwiic I2C driver:
52-
[Qwiic_I2C_Py](https://github.com/sparkfun/Qwiic_I2C_Py)
55+
The package is primarily installed using the `pip3` command, downloading the package from the Python Index - "PyPi".
5356

54-
Documentation
55-
-------------
56-
The SparkFun qwiic TMP102 module documentation is hosted at [ReadTheDocs](https://qwiic-tmp102-py.readthedocs.io/en/latest/?)
57+
Note - the below instructions outline installation on a Linux-based (Raspberry Pi) system.
5758

58-
Installation
59-
---------------
60-
### PyPi Installation
59+
First, setup a virtual environment from a specific directory using venv:
60+
```sh
61+
python3 -m venv path/to/venv
62+
```
63+
You can pass any path as path/to/venv, just make sure you use the same one for all future steps. For more information on venv [click here](https://docs.python.org/3/library/venv.html).
64+
65+
Next, install the qwiic package with:
66+
```sh
67+
path/to/venv/bin/pip3 install sparkfun-qwiic-tmp102
68+
```
69+
Now you should be able to run any example or custom python scripts that have `import qwiic_tmp102` by running e.g.:
70+
```sh
71+
path/to/venv/bin/python3 example_script.py
72+
```
6173

62-
This repository is hosted on PyPi as the [sparkfun-qwiic-tmp102](https://pypi.org/project/sparkfun-qwiic-tmp102/) package. On systems that support PyPi installation via pip, this library is installed using the following commands
74+
### MicroPython Installation
75+
If not already installed, follow the [instructions here](https://docs.micropython.org/en/latest/reference/mpremote.html) to install mpremote on your computer.
6376

64-
For all users (note: the user must have sudo privileges):
77+
Connect a device with MicroPython installed to your computer and then install the package directly to your device with mpremote mip.
6578
```sh
66-
sudo pip install sparkfun-qwiic-tmp102
79+
mpremote mip install github:sparkfun/qwiic_tmp102_py
6780
```
68-
For the current user:
6981

82+
If you would also like to install the examples for this repository, issue the following mip command as well:
7083
```sh
71-
pip install sparkfun-qwiic-tmp102
84+
mprmeote mip install github:sparkfun/qwiic_tmp102_py@examples
7285
```
73-
To install, make sure the setuptools package is installed on the system.
7486

75-
Direct installation at the command line:
87+
### CircuitPython Installation
88+
If not already installed, follow the [instructions here](https://docs.circuitpython.org/projects/circup/en/latest/#installation) to install CircUp on your computer.
89+
90+
Ensure that you have the latest version of the SparkFun Qwiic CircuitPython bundle.
7691
```sh
77-
python setup.py install
92+
circup bundle-add sparkfun/Qwiic_Py
7893
```
7994

80-
To build a package for use with pip:
95+
Finally, connect a device with CircuitPython installed to your computer and then install the package directly to your device with circup.
8196
```sh
82-
python setup.py sdist
83-
```
84-
A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.
97+
circup install --py qwiic_tmp102
98+
```
99+
100+
If you would like to install any of the examples from this repository, issue the corresponding circup command from below. (NOTE: The below syntax assumes you are using CircUp on Windows. Linux and Mac will have different path seperators (i.e. "/" vs. "\"). See the [CircUp "example" command documentation](https://learn.adafruit.com/keep-your-circuitpython-libraries-on-devices-up-to-date-with-circup/example-command) for more information)
101+
85102
```sh
86-
cd dist
87-
pip install sparkfun-qwiic-tmp102-<version>.tar.gz
103+
circup example qwiic_tmp102\Example1-GetTemperature
104+
circup example qwiic_tmp102\Example2_One-Shot_Temperature_Reading
105+
88106
```
89107

90108
Example Use
91-
-------------
92-
See the examples directory for more detailed use examples.
109+
---------------
110+
Below is a quickstart program to print readings from the TMP102.
111+
112+
See the examples directory for more detailed use examples and [examples/README.md](https://github.com/sparkfun/qwiic_tmp102_py/blob/main/examples/README.md) for a summary of the available examples.
93113

94114
```python
95-
from __future__ import print_function
115+
96116
import qwiic_tmp102
97117
import time
98118
import sys
99119

100120
def runExample():
101121

102-
print("\nSparkFun Qwiic TMP102 Sensor Test Example\n")
122+
print("\nSparkFun Qwiic TMP102 Sensor Example 1\n")
103123
myTmpSensor = qwiic_tmp102.QwiicTmp102Sensor()
104124

105125
if myTmpSensor.is_connected == False:
@@ -111,10 +131,34 @@ def runExample():
111131

112132
print("Initialized.")
113133

134+
135+
myTmpSensor.set_fault(0)
136+
137+
myTmpSensor.set_alert_polarity(1) # Active HIGH
138+
139+
myTmpSensor.set_alert_mode(0) # Comparator Mode.
140+
141+
myTmpSensor.set_conversion_rate(2)
142+
143+
myTmpSensor.set_extended_mode(0)
144+
145+
myTmpSensor.set_high_temp_f(85.0) # set T_HIGH in F
146+
147+
myTmpSensor.set_low_temp_f(84.0) # set T_LOW in F
148+
114149
while True:
115-
print ("Temp in F: ", myTmpSensor.read_temp_f())
116-
print ("Temp in C: ", myTmpSensor.read_temp_c())
117-
print ("--------------------------------------------")
150+
myTmpSensor.wakeup()
151+
152+
temperature = myTmpSensor.read_temp_f()
153+
154+
alertRegisterState = myTmpSensor.alert() # read the Alert from register
155+
156+
myTmpSensor.sleep()
157+
158+
print("Temperature: ", temperature)
159+
print("Alert Register: ", alertRegisterState)
160+
time.sleep(2)
161+
118162

119163
if __name__ == '__main__':
120164
try:
@@ -123,6 +167,8 @@ if __name__ == '__main__':
123167
print("\nEnding Example 1")
124168
sys.exit(0)
125169

170+
171+
126172
```
127173
<p align="center">
128174
<img src="https://cdn.sparkfun.com/assets/custom_pages/3/3/4/dark-logo-red-flame.png" alt="SparkFun - Start Something">

docs/images/gh-banner.png

695 KB
Loading

examples/Example2_One-Shot_Temperature_Reading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Example for the TMP102 I2C Temperature Sensor
55
# Alex Wende @ SparkFun Electronics
66
# April 29th 2016
7-
7+
#
88
# This sketch connects to the TMP102 temperature sensor and enables the
99
# one-shot temperature measurement mode using the one_shot() function.
1010
# The function returns 0 until the temperature measurement is ready to

examples/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Sparkfun TMP102 Examples Reference
2+
Below is a brief summary of each of the example programs included in this repository. To report a bug in any of these examples or to request a new feature or example [submit an issue in our GitHub issues.](https://github.com/sparkfun/qwiic_tmp102_py/issues).
3+
4+
NOTE: Any numbering of examples is to retain consistency with the Arduino library from which this was ported.
5+
6+
## Example1-Gettemperature
7+
Simple Example for the Qwiic TMP102 Device
8+
9+
## Example2 One-Shot Temperature Reading
10+
This sketch connects to the TMP102 temperature sensor and enables the
11+
one-shot temperature measurement mode using the one_shot() function.
12+
The function returns 0 until the temperature measurement is ready to
13+
read (takes around 25ms). After the measurment is read, the TMP102 is
14+
placed back into sleep mode before the loop is repeated. This can be
15+
useful to save power or increase the continuous conversion rate from
16+
8Hz up to a maximum of 40Hz.
17+
18+
This code is beerware; if you see me (or any other SparkFun employee) at
19+
the local, and you've found our code helpful, please buy us a round!
20+
21+
Distributed as-is; no warranty is given.
22+
23+

pyproject.toml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
4+
[project]
5+
name = "sparkfun_qwiic_tmp102"
6+
version = "0.0.4"
7+
description = long_description
8+
readme = "DESCRIPTION.rst"
9+
10+
authors = [{name="Sparkfun Electronics", email="[email protected]"}]
11+
dependencies = ["sparkfun_qwiic_i2c"]
12+
13+
classifiers=[
14+
# How mature is this project? Common values are
15+
# 3 - Alpha
16+
# 4 - Beta
17+
# 5 - Production/Stable
18+
"Development Status :: 5 - Production/Stable",
19+
20+
# Indicate who your project is intended for
21+
"Intended Audience :: Developers",
22+
"Topic :: Software Development :: Build Tools",
23+
24+
# Pick your license as you wish (should match "license" above)
25+
"License :: OSI Approved :: MIT License",
26+
27+
# Specify the Python versions you support here. In particular, ensure
28+
# that you indicate whether you support Python 2, Python 3 or both.
29+
"Programming Language :: Python :: 3.5",
30+
"Programming Language :: Python :: 3.6",
31+
"Programming Language :: Python :: 3.7",
32+
"Programming Language :: Python :: 3.8",
33+
"Programming Language :: Python :: 3.9",
34+
"Programming Language :: Python :: 3.10",
35+
"Programming Language :: Python :: 3.11",
36+
"Programming Language :: Python :: 3.12",
37+
"Programming Language :: Python :: 3.13",
38+
"Programming Language :: Python :: 3.14",
39+
"Programming Language :: Python :: Implementation :: MicroPython",
40+
# NOTE: CircuitPython is also supported, but no classifier exists for it
41+
]
42+
43+
keywords = ["electronics, maker"]
44+
45+
[project.urls]
46+
homepage = "https://www.sparkfun.com/products/16304"
47+
48+
[tool.setuptools]
49+
py-modules = ["qwiic_tmp102"]

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)