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

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

soil_power_sensor_protobuf-2.3.1.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

soil_power_sensor_protobuf-2.3.1-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for soil_power_sensor_protobuf-2.3.1.tar.gz
Algorithm Hash digest
SHA256 498e2aabe9fce99ca78aab2a089b7e5312563416ae3eede54061b63af58e4e61
MD5 d06bbed3c2e35aecef6c6cff14388364
BLAKE2b-256 4a3ba8b790c19585f9efa03f2c4080a2f7fe257dc3d6b5f0ded091d01f186f67

See more details on using hashes here.

Provenance

The following attestation bundles were made for soil_power_sensor_protobuf-2.3.1.tar.gz:

Publisher: publish-python.yaml on jlab-sensing/ENTS-node-firmware

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for soil_power_sensor_protobuf-2.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 568083897d4fc14128ed2f692d0bfff29f134674ac99f24917ec36372c725d52
MD5 159d30083589b04c22c176cc61c79c89
BLAKE2b-256 daed56ecf37931f635de4a0612cd313b4141496be4957eb69c1f2e54c4480505

See more details on using hashes here.

Provenance

The following attestation bundles were made for soil_power_sensor_protobuf-2.3.1-py3-none-any.whl:

Publisher: publish-python.yaml on jlab-sensing/ENTS-node-firmware

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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