Skip to content

myDevicesIoT/CayenneLPP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cayenne Low Power Payload

Overview

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.

Additionally, the Cayenne LPP allows the device to send different sensor data in different frames. In order to do that, each sensor data must be prefixed with two bytes:

  • Data Channel: Uniquely identifies each sensor in the device across frames, eg. “indoor sensor”
  • Data Type: Identifies the data type in the frame, eg. “temperature”.

Payload structure

1 Byte 1 Byte N Bytes 1 Byte 1 Byte M Bytes ...
Data1 Ch. Data1 Type Data1 Data2 Ch. Data2 Type Data2 ...

Data Types

Data Types conform to the IPSO Alliance Smart Objects Guidelines, which identifies each data type with an “Object ID”. However, as shown below, a conversion is made to fit the Object ID into a single byte.

LPP_DATA_TYPE = IPSO_OBJECT_ID - 3200

Each data type can use 1 or more bytes to send the data according to the following table.

Type IPSO LPP Hex Data Size Data Resolution per bit
Digital Input 3200 0 0 1 1
Digital Output 3201 1 1 1 1
Analog Input 3202 2 2 2 0.01 Signed
Analog Output 3203 3 3 2 0.01 Signed
Illuminance Sensor 3301 101 65 2 1 Lux Unsigned MSB
Presence Sensor 3302 102 66 1 1
Temperature Sensor 3303 103 67 2 0.1 °C Signed MSB
Humidity Sensor 3304 104 68 1 0.5 % Unsigned
Accelerometer 3313 113 71 6 0.001 G Signed MSB per axis
Barometer 3315 115 73 2 0.1 hPa Unsigned MSB
Gyrometer 3334 134 86 6 0.01 °/s Signed MSB per axis
GPS Location 3336 136 88 9 Latitude : 0.0001 ° Signed MSB
Longitude : 0.0001 ° Signed MSB
Altitude : 0.01 meter Signed MSB

Examples

Device with 2 temperature sensors

Payload (Hex) 03 67 01 10 05 67 00 FF
Data Channel Type Value
03 ⇒ 3 67 ⇒ Temperature 0110 = 272 ⇒ 27.2°C
05 ⇒ 5 67 ⇒ Temperature 00FF = 255 ⇒ 25.5°C

Device with temperature and acceleration sensors

Frame N

Payload (Hex) 01 67 FF D7
Data Channel Type Value
01 ⇒ 1 67 ⇒ Temperature FFD7 = -41 ⇒ -4.1°C

Frame N+1

Payload (Hex) 06 71 04 D2 FB 2E 00 00
Data Channel Type Value
06 ⇒ 6 71 ⇒ Accelerometer X: 04D2 = +1234 ⇒ +1.234G
Y: FB2E = -1234 ⇒ -1.234G
Z: 0000 = 0 ⇒ 0G

Example use

#include 'CayenneLPP.h';

#define MAX_SIZE 200; // depends on spreading factor and frequency used

CayenneLPP Payload(MAX_SIZE);

float celsius = -4.1;
float accel[] = {1.234, -1.234, 0};
float rh = 30;
float hpa = 1014.1;
float latitude = 42.3519;
float longitude = -87.9094;
float altitude:10

int size = 0;

Payload.reset();
size = Payload.addTemperature(0, celsius);

if (size == 0) {
    // not enough byte left to add the data
}

else {
    // add function returned current payload size
}


Payload.addAccelerometer(1, accel[0], accel[1], accel[2]);
Payload.addRelativeHumidity(3, rh);
Payload.addBarometricPressure(4, hpa);
Payload.addGPS(5, latitude, longitude, altitude);

// Call LoRaWAN library to send the frame
LORA_SEND(Payload.getBuffer(), Payload.getSize());