Skip to main content

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
  }
}

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 discover tests

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

soil_power_sensor_protobuf-2.0.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file soil_power_sensor_protobuf-2.0.0.tar.gz.

File metadata

File hashes

Hashes for soil_power_sensor_protobuf-2.0.0.tar.gz
Algorithm Hash digest
SHA256 fe6638307f484e0d5a1e752c2d4f1568eb93e4005db3e0b99ddd051ddee0ac24
MD5 3a1f648d076a95f639fe7ec162d2b460
BLAKE2b-256 88b542dc0acd239444327830a60919fa6404cb0f1884810634d2a53eea089ccb

See more details on using hashes here.

File details

Details for the file soil_power_sensor_protobuf-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for soil_power_sensor_protobuf-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a762c0749621e384f6b86f10bf0f902c1b65468f778a17914af8f5fd31b817d
MD5 884291dfdc27fffc063de8a4ea711e89
BLAKE2b-256 84ab65c3638b7d3aca771029d3804cddc7b0497c8468968630d314c6d9fe468a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page