Skip to content

Commit f78dbbd

Browse files
Update README.md and add examples reference
1 parent 5b57ceb commit f78dbbd

File tree

3 files changed

+99
-59
lines changed

3 files changed

+99
-59
lines changed

README.md

Lines changed: 82 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,77 @@
1-
Qwiic_Soil_Moisture_Sensor_Py
2-
===============
1+
![Qwiic Soil Moisture Sensor Python Package](docs/images/soil_moisture_sensor-gh-banner-py.png "qwiic Soil Moisture Sensor 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-soil-moisture-sensor/" alt="Package">
10-
<img src="https://img.shields.io/pypi/pyversions/sparkfun-qwiic_soil_moisture_sensor.svg" /></a>
11-
<a href="https://github.com/sparkfun/Qwiic_Soil_Moisture_Sensor_Py/issues" alt="Issues">
12-
<img src="https://img.shields.io/github/issues/sparkfun/Qwiic_Soil_Moisture_Sensor_Py.svg" /></a>
13-
<a href="https://qwiic-soil-moisture-sensor-py.readthedocs.io/en/latest/?" alt="Documentation">
14-
<img src="https://readthedocs.org/projects/qwiic-soil-moisture-sensor-py/badge/?version=latest&style=flat" /></a>
15-
<a href="https://github.com/sparkfun/Qwiic_Soil_Moisture_Sensor_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 Soil Moisture Sensor - Python Package
204

21-
</p>
5+
![PyPi Version](https://img.shields.io/pypi/v/sparkfun_qwiic_soil_moisture_sensor)
6+
![GitHub issues](https://img.shields.io/github/issues/sparkfun/qwiic_soil_moisture_sensor_py)
7+
![License](https://img.shields.io/github/license/sparkfun/qwiic_soil_moisture_sensor_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_soil_moisture_sensor_py/classqwiic__soil__moisture__sensor_1_1_qwiic_soil_moisture_sensor.html)
2210

23-
<img src="https://cdn.sparkfun.com/assets/parts/1/6/8/4/8/17731-SparkFun_Qwiic_Soil_Moisture_Sensor-01.jpg" align="right" width=300 alt="SparkFun Qwiic Soil Moisture Sensor">
11+
The SparkFun Qwiic Soil Moisture Sensor provides a simple and cost effective solution for adding soil moisture sensing 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 Soil Moisture Sensor. This package works with Python, MicroPython and CircuitPython.
2514

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

28-
This python package is a port of the existing [SparkFun Soil Moisture Sensor Arduino Examples](https://github.com/sparkfun/Zio-Qwiic-Soil-Moisture-Sensor/tree/master/Firmware/Qwiic%20Soil%20Moisture%20Sensor%20Examples)
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_soil_moisture_sensor_py/classqwiic__soil__moisture__sensor_1_1_qwiic_soil_moisture_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 Qwiic Soil Moisture Sensor via a single Qwiic cable. This includes reading the moisture level, turning on and off the LED, and more. The capabilities of the moisture sensor 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 Qwiic Soil Moisture Sensor](https://www.sparkfun.com/sparkfun-qwiic-soil-moisture-sensor.html)
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)
4143

42-
Supported Platforms
43-
--------------------
44-
The qwiic Soil Moisture Sensor 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)
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.
4846
49-
Dependencies
50-
--------------
51-
This driver package depends on the qwiic I2C driver:
52-
[Qwiic_I2C_Py](https://github.com/sparkfun/Qwiic_I2C_Py)
47+
## Installation
5348

54-
Documentation
55-
-------------
56-
The SparkFun qwiic Soil Moisture Sensor module documentation is hosted at [ReadTheDocs](https://qwiic-soil-moisture-sensor-py.readthedocs.io/en/latest/?)
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.
5750

58-
Installation
59-
---------------
60-
### PyPi Installation
51+
### Python
6152

62-
This repository is hosted on PyPi as the [sparkfun-qwiic-soil-moisture-sensor](https://pypi.org/project/sparkfun-qwiic-soil-moisture-sensor/) package. On systems that support PyPi installation via pip, this library is installed using the following commands
53+
The package is primarily installed using the `pip` command, downloading the package from the Python Index - "PyPi". Note - the below instructions outline installation an Linux-based (Raspberry Pi) system.
54+
55+
#### PyPi Installation
56+
57+
The SparkFun Qwiic Soil Moisture Sensor Python package is part of the overall SparkFun Qwiic Python package which is hosted on PyPi. On systems that support PyPi installation via pip, this library is installed using the following commands
6358

6459
For all users (note: the user must have sudo privileges):
6560
```sh
66-
sudo pip install sparkfun-qwiic-soil-moisture-sensor
61+
sudo pip install sparkfun-qwiic
6762
```
6863
For the current user:
6964

7065
```sh
71-
pip install sparkfun-qwiic-soil-moisture-sensor
66+
pip install sparkfun-qwiic
7267
```
68+
---
69+
---
70+
> [!CAUTION]
71+
> **TODO** Put together how this works with the new virtual environments used with the latest Python install
72+
---
73+
---
74+
#### Local Installation
7375
To install, make sure the setuptools package is installed on the system.
7476

7577
Direct installation at the command line:
@@ -84,24 +86,47 @@ python setup.py sdist
8486
A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.
8587
```sh
8688
cd dist
87-
pip install sparkfun-qwiic-soil-moisture-sensor-<version>.tar.gz
89+
pip install sparkfun_qwiic_soil_moisture_sensor-<version>.tar.gz
90+
```
91+
92+
### MicroPython Installation
93+
If not already installed, follow the [instructions here](https://docs.micropython.org/en/latest/reference/mpremote.html) to install mpremote on your computer.
94+
95+
Connect a device with MicroPython installed to your computer and then install the package directly to your device with mpremote mip.
96+
```sh
97+
mpremote mip install github:sparkfun/qwiic_soil_moisture_sensor_py
98+
```
99+
100+
### CircuitPython Installation
101+
If not already installed, follow the [instructions here](https://docs.circuitpython.org/projects/circup/en/latest/#installation) to install CircUp on your computer.
102+
103+
Ensure that you have the latest version of the SparkFun Qwiic CircuitPython bundle.
104+
```sh
105+
circup bundle-add sparkfun/Qwiic_Py
106+
```
107+
108+
Finally, connect a device with CircuitPython installed to your computer and then install the package directly to your device with circup.
109+
```sh
110+
circup install --py qwiic_soil_moisture_sensor
88111
```
89112

90113
Example Use
91-
-------------
92-
See the examples directory for more detailed use examples.
114+
---------------
115+
Below is a quickstart program to print moisture level and toggle the LED on the Soil Moisture Sensor.
116+
117+
See the examples directory for more detailed use examples and [examples/README.md](https://github.com/sparkfun/qwiic_soil_moisture_sensor_py/blob/main/examples/README.md) for a summary of the available examples.
93118

94119
```python
95-
from __future__ import print_function
96120
import qwiic_soil_moisture_sensor
97-
121+
import time
122+
import sys
98123

99124
def runExample():
100125

101-
print("\nSparkFun qwiic soil moisture sensor Example 1\n")
126+
print("\nSparkFun Qwiic Soil Moisture Sensor Example 1\n")
102127
mySoilSensor = qwiic_soil_moisture_sensor.QwiicSoilMoistureSensor()
103128

104-
if mySoilSensor.connected == False:
129+
if mySoilSensor.is_connected() == False:
105130
print("The Qwiic Soil Moisture Sensor device isn't connected to the system. Please check your connection", \
106131
file=sys.stderr)
107132
return
@@ -117,15 +142,13 @@ def runExample():
117142
time.sleep(1)
118143
mySoilSensor.led_off()
119144
time.sleep(1)
120-
145+
121146
if __name__ == '__main__':
122147
try:
123148
runExample()
124149
except (KeyboardInterrupt, SystemExit) as exErr:
125150
print("\nEnding Example 1")
126-
sys.exit(0)
127-
128-
151+
sys.exit(0)
129152
```
130153
<p align="center">
131154
<img src="https://cdn.sparkfun.com/assets/custom_pages/3/3/4/dark-logo-red-flame.png" alt="SparkFun - Start Something">
464 KB
Loading

examples/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Sparkfun Soil Moisture Sensor 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_bme280_py/issues).
3+
4+
## Example 1: Basic Readings
5+
This example demonstrates basic bringup of the Qwiic Soil Moisture Sensor to print moisture level and toggle the LED on and off.
6+
7+
The key methods showcased by this example are:
8+
9+
- [read_moisture_level()](https://docs.sparkfun.com/qwiic_soil_moisture_sensor_py/classqwiic__soil__moisture__sensor_1_1_qwiic_soil_moisture_sensor.html#a21ef69d794e2786b5eb3ef7881ba95db)
10+
- [led_on()](https://docs.sparkfun.com/qwiic_soil_moisture_sensor_py/classqwiic__soil__moisture__sensor_1_1_qwiic_soil_moisture_sensor.html#a344fb9aa9120ca97555afc052aa94aa4)
11+
- [led_off()](https://docs.sparkfun.com/qwiic_soil_moisture_sensor_py/classqwiic__soil__moisture__sensor_1_1_qwiic_soil_moisture_sensor.html#a9799401c60ab796e346a49718a98f601)
12+
13+
14+
## Example 2: Change I2C Address
15+
This example demonstrates how to change the I2C address on the Qwiic Soil Moisture Sensor. The user is prompted for a new I2C address in the legal range 0x08 to 0x3F. Then, the address of the sensor is changed to the user's selection.
16+
17+
The key method showcased by this example is [change_address()](https://docs.sparkfun.com/qwiic_soil_moisture_sensor_py/classqwiic__soil__moisture__sensor_1_1_qwiic_soil_moisture_sensor.html#ad3b91fdbd9f8190798af7ee2227d4d63)

0 commit comments

Comments
 (0)