Python package for encoding/decoding measurement data from the Soil Power Sensor
Project description
Soil Power Sensor Python Protobuf Bindings {#protobuf-python}
The soil power sensor protobuf protocol is implemented as a Python package that allows for Measurement messages to be decoded into a dictionary and Response messages to be encoded. The generated files from protobuf are also accessible for more complex use cases.
Installation
Use the following to install the soil-power-sensor-protobuf package with pip:
pip install soil-power-sensor-protobuf
Usage
The following example code demonstrates decoding the measurement message and encoding a response.
from soil_power_sensor_protobuf import encode, decode
# get data encoded by the soil power sensor
data = ...
meas_dict = decode(data)
# process data
...
# send response
resp_str = encode(success=True)
The formatting of the dictionary depends on the type of measurement sent. The key type is included on all measurement types and can be used to determine the type of message. See the source *.proto files to get the full list of types to get the full list of types and keys. A list is provided in Message Types. The Python protobuf API uses camel case when naming keys. The key ts is in ISO 8601 format as a string.
Message Types
Type power
meas_dict = {
"type": "power",
"loggerId": ...,
"cellId": ...,
"ts": ...,
"data": {
"voltage": ...,
"current": ...
},
"data_type": {
"voltage": float,
"voltage": float
}
}
Type teros12
meas_dict = {
"type": "teros12",
"loggerId": ...,
"cellId": ...,
"ts": ...,
"data": {
"vwcRaw": ...,
"vwcAdj": ...,
"temp": ...,
"ec": ...
},
"data_type": {
"vwcRaw": float,
"vwcAdj": float,
"temp": float,
"ec": int
}
}
Type bme280 with raw=True (default)
meas_dict = {
"type": "bme280",
"loggerId": ...,
"cellId": ...,
"ts": ...,
"data": {
"pressure": ...,
"temperature": ...,
"humidity": ...,
},
"data_type": {
"pressure": int,
"temperature": int,
"humidity": int,
}
}
Type bme280 with raw=False
meas_dict = {
"type": "bme280",
"loggerId": ...,
"cellId": ...,
"ts": ...,
"data": {
"pressure": ...,
"temperature": ...,
"humidity": ...,
},
"data_type": {
"pressure": float,
"temperature": float,
"humidity": float,
}
}
Testing
To run the package tests, create a virtual environment, install as an editable package, and run unittest.
python -m venv .venv
source .venv/bin/activate
pip install -e .
python -m unittest
Project details
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 soil_power_sensor_protobuf-2.3.0.tar.gz.
File metadata
- Download URL: soil_power_sensor_protobuf-2.3.0.tar.gz
- Upload date:
- Size: 24.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9aca5a748640da38c6cb603bcc8cad0308c485c695f9056bc29966780bedaa5
|
|
| MD5 |
4dc8bf6aacc041d906ed80a68f0af489
|
|
| BLAKE2b-256 |
9cc5ae81840e1700747119bba0cc1597111b81b297034417bde3036299aeb0e6
|
Provenance
The following attestation bundles were made for soil_power_sensor_protobuf-2.3.0.tar.gz:
Publisher:
publish-python.yaml on jlab-sensing/ENTS-node-firmware
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
soil_power_sensor_protobuf-2.3.0.tar.gz -
Subject digest:
a9aca5a748640da38c6cb603bcc8cad0308c485c695f9056bc29966780bedaa5 - Sigstore transparency entry: 174653924
- Sigstore integration time:
-
Permalink:
jlab-sensing/ENTS-node-firmware@fef583f6ca6305860833ed78d9076e0aa11ee011 -
Branch / Tag:
refs/tags/2.3.0 - Owner: https://github.com/jlab-sensing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yaml@fef583f6ca6305860833ed78d9076e0aa11ee011 -
Trigger Event:
push
-
Statement type:
File details
Details for the file soil_power_sensor_protobuf-2.3.0-py3-none-any.whl.
File metadata
- Download URL: soil_power_sensor_protobuf-2.3.0-py3-none-any.whl
- Upload date:
- Size: 29.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccce0650f76aa5cbc84dc137dd4700b4e25c0df68b6817c88d7726ba87efcc0e
|
|
| MD5 |
aef6e6524dee7960b4c3bcbf36b1b94c
|
|
| BLAKE2b-256 |
7f7bef9d65e9664faa4cef98c11a259a66ae1efccba2b34f9790dafd83f437f1
|
Provenance
The following attestation bundles were made for soil_power_sensor_protobuf-2.3.0-py3-none-any.whl:
Publisher:
publish-python.yaml on jlab-sensing/ENTS-node-firmware
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
soil_power_sensor_protobuf-2.3.0-py3-none-any.whl -
Subject digest:
ccce0650f76aa5cbc84dc137dd4700b4e25c0df68b6817c88d7726ba87efcc0e - Sigstore transparency entry: 174653926
- Sigstore integration time:
-
Permalink:
jlab-sensing/ENTS-node-firmware@fef583f6ca6305860833ed78d9076e0aa11ee011 -
Branch / Tag:
refs/tags/2.3.0 - Owner: https://github.com/jlab-sensing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yaml@fef583f6ca6305860833ed78d9076e0aa11ee011 -
Trigger Event:
push
-
Statement type: