Skip to main content

Encoder and Decoder for CayenneLLP

Project description

PyCayenneLPP

Travis-CI Codacy Badge Codacy Badge PyPi GitHub

A Cayenne Low Power Payload (CayenneLPP) decoder and encoder written in Python.

PyCayenneLPP offers a concise interface with proper encoding and decoding functionality for the CayenneLPP format suporting many sensor types. Further, the project aims for overall high code quality and good test coverage.

See also myDevicesIoT/CayenneLPP for more information on the format and a reference implementation in C++.

The project is under active development. Releases will be published on the fly as soon as a certain number of new features and fixes have been made.

Supported Data Types

The following table lists the currently supported data types with the LPP code (which equals IPSO code - 3200), data size in bytes, and data dimensions.

Type Name LPP Size Dim
Digital Input 0 1 1
Digital Output 1 1 1
Analog Input 2 2 1
Analog Output 3 2 1
Generic 100 4 1
Illuminance 101 2 1
Presence 102 1 1
Temperature 103 2 1
Humidity 104 1 1
Accelerometer 113 6 3
Barometer 115 2 1
Voltage 116 2 1
Load 122 3 1
Unix Time 133 4 1
Gyrometer 134 6 3
GPS Location 136 9 3

Getting Started

PyCayenneLPP does not have any external dependencies and only uses builtin functions and types of Python 3. It is compatible with all the latest and officially supported Python versions 3.6 and above, though even Python 3.4 will do.

Since PyCayenneLPP 1.2.0 MicroPython is officially supported, and published as a separate package under micropython-pycayennelpp.

Python 3 Prerequisites

The PyCayenneLPP package is available via PyPi using pip. To install it run:

pip3 install pycayennelpp

MicroPython Prerequisites

Using MicroPythons upip module PyCayenneLPP can be installed as follows within MicroPython:

import upip
upip.install("micropython-pycayennelpp")

Or alternatively run with in a shell:

micropython -m upip install micropython-pycayennelpp

Usage Examples

The following show how to utilise PyCayenneLPP in your own application to encode and decode data into and from CayenneLPP. The code snippets work with standard Python 3 as well as MicroPython, assuming you have installed the PyCayenneLPP package as shown above.

Encoding

from cayennelpp import LppFrame


# create empty frame
frame = LppFrame()
# add some sensor data
frame.add_temperature(0, -1.2)
frame.add_humidity(6, 34.5)
# get byte buffer in CayenneLPP format
buffer = bytes(frame)

Decoding

from cayennelpp import LppFrame


# byte buffer in CayenneLPP format with 1 data item
# i.e. on channel 1, with a temperature of 25.5C
buffer = bytearray([0x01, 0x67, 0x00, 0xff])
# create frame from bytes
frame = LppFrame().from_bytes(buffer)
# print the frame and its data
print(frame)

Contributing

Contributing to a free open source software project can take place in many different ways. Feel free to open issues and create pull requests to help improving this project. Each pull request has to pass some automatic tests and checks run by Travis-CI before being merged into the master branch.

Please take note of the contributing guidelines and the Code of Conduct.

License

This is a free open source software project published under the MIT License.

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

pycayennelpp-2.0.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

pycayennelpp-2.0.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycayennelpp-2.0.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for pycayennelpp-2.0.0.tar.gz
Algorithm Hash digest
SHA256 5494c83a81b73ae9da0bfeb8e824b90586d09efe48f21d62b5b5c6a4a89c04f4
MD5 fe47d660fe7f813fbd7f27feeb592a32
BLAKE2b-256 72c50d6833246adf2320fc59c3b9d8bde291e8161f7e80d3c527ed5898c0177d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycayennelpp-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for pycayennelpp-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d11ed8b1e4e84355212fe22a24732273e69009b7cdef0d609793d3dc61d6ad9
MD5 9911ab9feff1e5b1a890bac50bae4794
BLAKE2b-256 c91e7bc5cbde7aaa0e6c627f9827cbd6497a8c62557ac913a168d540e3818389

See more details on using hashes here.

Supported by

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