• by


This week I was messing with some payload formats and I came to the conclusion the easiest and smartest way make a package is by using CayenneLPP.

Cayenne Low Power Payload (LPP) is a library designed to make packages for LPWAN networks such as LoRa and LoRaWAN.

This video below shows a practical example and compares several package formats for LoRa applications.


Cayenne LPP has several specific functions for some types of packages, such as humidity, temperature, pressure, GPS, among others.

Here some functions… Read more about Cayenne LPP

uint8_t addDigitalInput(uint8_t channel, uint8_t value);
uint8_t addDigitalOutput(uint8_t channel, uint8_t value);
uint8_t addAnalogInput(uint8_t channel, float value);
uint8_t addAnalogOutput(uint8_t channel, float value);
uint8_t addLuminosity(uint8_t channel, uint16_t lux);
uint8_t addPresence(uint8_t channel, uint8_t value);
uint8_t addTemperature(uint8_t channel, float celsius);
uint8_t addRelativeHumidity(uint8_t channel, float rh);
uint8_t addAccelerometer(uint8_t channel, float x, float y, float z);
uint8_t addBarometricPressure(uint8_t channel, float hpa);
uint8_t addGyrometer(uint8_t channel, float x, float y, float z);
uint8_t addGPS(uint8_t channel, float latitude, float longitude, float meters);

In general, the library adds the channel, data type, and compressed data to the buffer. This way you have a smart and compact package.

Now the receiver or application needs to decode this packet. The Thing Network has this solution built into the LoRaWAN application.


So the bytes package is decoded into a Json and can easily be integrated by any application.


Thinking of this I create a Library to decode the CayenneLPP to a Json payload. Based on the TTN decoder fields here is the CayenneLPPDecode.


CayenneLPPDecode allows you to decode CayenneLPP payloads to the JSON format, in this case, ArduinoJson library.

Here’s an example to test a basic encode/decode.

#include <CayenneLPPDecode.h>

void setup() {
  DynamicJsonBuffer jsonBuffer;
  CayenneLPP lpp(64);
  CayenneLPPDecode lppd;

  JsonObject& root = jsonBuffer.createObject();


  lpp.addDigitalInput(1, 0);
  lpp.addDigitalOutput(2, 1);
  lpp.addAnalogInput(3, 1.23f);
  lpp.addAnalogOutput(4, 3.45f);
  lpp.addLuminosity(5, 20304);
  lpp.addPresence(6, 1);
  lpp.addTemperature(7, 26.5f);
  lpp.addRelativeHumidity(8, 86.6f);
  lpp.addAccelerometer(9, 1.234f, -1.234f, 0.567f);
  lpp.addBarometricPressure(10, 1023.4f);
  lpp.addGyrometer(1, -12.34f, 45.56f, 89.01f);
  lpp.addGPS(1, -12.34f, 45.56f, 9.01f);

  lppd.write(lpp.getBuffer(), lpp.getSize());


void loop() {


This code return on serial port the JSON payload, on the case the same JSON from TTN. Isn’t on alphabetical order but is the same thing.

  "digital_in_1": 0,
  "digital_out_2": 1,
  "analog_in_3": 1.23,
  "analog_out_4": 3.45,
  "luminosity_5": 20304,
  "presence_6": 1,
  "temperature_7": 26.5,
  "relative_humidity_8": 86.5,
  "accelerometer_9": {
    "x": 1.234,
    "y": -1.234,
    "z": 0.567
  "barometric_pressure_10": 1023.4,
  "gyrometer_1": {
    "x": -12.34,
    "y": 45.56,
    "z": 89.01
  "gps_1": {
    "latitude": -12.34,
    "longitude": 45.56,
    "altitude": 9.01

I create an example with LoRa hows does a similar thing, but send the data over the LoRa communication and decode when receiving some payload.

Download CayenneLPPDecode and check out!

See you next time!