cayenne.lpp.decode action
This trigger action accepts a decoded string and converts it to a binary encoded string.
Action
The Cayenne LPP (Low Power Payload) provides a convenient way to send data over LPWAN (Low-power, wide-area networks). The LPP protocol https://github.com/myDevicesIoT/cayenne-docs/blob/master/docs/allows for compact binary packets to be sent and decoded without knowledge about the data structure.
The Cayenne LPP enables the devices to send different sensor data in different frames. Each sensor data is prefixed with two bytes that contain the Data Channel and Data Type information.
The format of the data is as follows:
Data1 Channel |
Data1 Type |
Data |
Data2 Channel |
Data2 Type |
Data |
... |
---|---|---|---|---|---|---|
1 Byte |
1 Byte |
N Bytes |
1 Byte |
1 Byte |
N Bytes |
... |
-
Data Channel: Uniquely identifies each sensor in the device across frames. For example, Temperature sensor
-
Data Type: Identifies the data type in the frame. For example, Temperature
Each data type uses one or more bytes to send the data according:
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
For example, Device with temperature and acceleration 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 |
Payload (Hex) |
01 67 FF D7 |
|
Data Channel |
Type |
Value |
01 ⇒ 1 |
67 ⇒Temperature |
FFD7 = -41 ⇒ -4.1°C |
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 |
Payload (Hex) |
01 88 06 76 5f f2 96 0a 00 03 e8 |
|
Data Channel |
Type |
Value |
01 ⇒ 1 |
88 ⇒GPS |
Latitude: 06765f ⇒ 42.3519 Longitude: F2960a ⇒ -87.9094 Altitude: 0003E8 ⇒ 10 meters |
Action
On the Adding trigger page, under Binary, drag cayenne.lpp.decode to the canvas.
Canvas
The left routing point (red) is the failure route. This route will be taken if there is an error during execution.
The right routing point (green) is the success route. This route will be taken if action executes successfully.
Form
Parameters
Name |
Type |
Required |
Description |
---|---|---|---|
Input |
String |
Yes |
The cayenne.lpp string to be converted. |
Action variable
This action returns multiple values for each channel sent in the packet. In the examples below, Y is the channel number that is received.
Name |
Type |
Description |
---|---|---|
$(action.X.channels.Y.name) |
String |
The name of the sensor type, this will be a human-readable name such as Analog Input or Temperature Sensor. |
$(action.X.channels.Y.key) |
String |
The string key for the sensor type, this will be ideal as a programmatic key such as analogIn or temperature. |
$(action.X.channels.Y.value) |
Varies |
For numerical sensor types, this value will be a floating point value. For accelerometer and gyrometer, the result will be an object with x, y, and z values. For GPS, the result will be an object with lat, lng, and alt fields. |