Cayenne LPP

TTN version: TTNv3
Last updated: January 21, 2023

The Cayenne Low Power Payload (LPP) provides a convenient and easy way to send data over LPWAN networks such as LoRaWAN. The Cayenne LPP is compliant with the payload size restriction, which can be lowered down to 11 bytes, and allows the device to send multiple sensor data at one time. Cayenne LPP has several specific functions for some types of data, such as humidity, temperature, pressure, GPS and more.

 

Original LPPv1 data types
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);

 

Additional data types
uint8_t addUnixTime(uint8_t channel, uint32_t value);
uint8_t addGenericSensor(uint8_t channel, float value);
uint8_t addVoltage(uint8_t channel, float value);
uint8_t addCurrent(uint8_t channel, float value);
uint8_t addFrequency(uint8_t channel, uint32_t value);
uint8_t addPercentage(uint8_t channel, uint32_t value);
uint8_t addAltitude(uint8_t channel, float value);
uint8_t addPower(uint8_t channel, uint32_t value);
uint8_t addDistance(uint8_t channel, float value);
uint8_t addEnergy(uint8_t channel, float value);
uint8_t addDirection(uint8_t channel, float value);
uint8_t addSwitch(uint8_t channel, uint32_t value);
uint8_t addConcentration(uint8_t channel, uint32_t value);
uint8_t addColour(uint8_t channel, uint8_t r, uint8_t g, uint8_t b);

 

More information can be found in the Cayenne LPP documentation.

 

Arduino IDE setup

  1. Run Arduino IDE.
  2. In the Arduino IDE Library Manager search CayenneLPP by Electronic Cats and install it.

 

Cayenne LPP in program

As an example, we will use a program for a Temperature and Humidity sensor using Adafruit Feather 32u4 RFM95 LoRa Radio and DHT22.

  1. At the top of the program you can see:
    #include <CayenneLPP.h>      // Cayenne Low Power Payload (LPP)
    CayenneLPP lpp(51);
  2. In the function void do_send(osjob_t* j) you can see that first the lpp is reset, which deletes the previously added data (temperature and humidity). Then the current measured temperature is added to lpp in channel 1 and humidity in channel 2. When you have all the data you want to send in the lpp, put the lpp buffer and its size in the LMIC_setTxData2 function call.
    lpp.reset();
    lpp.addTemperature(1, temp);                                // Add the current temperature into channel 1
    lpp.addRelativeHumidity(2, humi);                           // Add the current humidity into channel 2
    LMIC_setTxData2(1, lpp.getBuffer(), lpp.getSize(), 0);      // Prepare upstream data transmission at the next possible time
    

 

The Things Stack setup

 Original LPPv1 data types
  1. In TTS -> Applications -> YourAppName -> Payload formatters -> Uplink change Formatter type to CayenneLPP.
  2. Save changes.Cayenne_TTS_LPPv1

 

Additional data types and Original LPPv1 data types
  1. In TTS -> Applications -> YourAppName -> Payload formatters -> Uplink change Formatter type to Custom Javascript formatter.Cayenne_TTS_Advanced_1
  2. To the Formatter code field copy and paste Cayenne LPP Decoder.
  3. Scroll down and delete the dot on line 165 and 166.Cayenne_TTS_Advanced_2
  4. Save changes.Cayenne_TTS_Advanced_3