Cayenne Low Power Payload

Dependents:   LORAWAN-TTN-CAYENNE-LM35 ER4Lora gps_accelerometer sgam_mdw_test ... more

Committer:
eptak
Date:
Tue Dec 06 20:51:26 2016 +0000
Revision:
5:a67d5a7955c7
Parent:
4:8d32c35e74ad
Completed GPS example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
eptak 2:ac824f095591 1 # Cayenne Low Power Payload
eptak 2:ac824f095591 2 Payload builder library
eptak 2:ac824f095591 3
eptak 2:ac824f095591 4
eptak 2:ac824f095591 5 # Example use
eptak 2:ac824f095591 6 ```
eptak 2:ac824f095591 7 #include 'CayenneLPP.h';
eptak 2:ac824f095591 8
eptak 2:ac824f095591 9 #define MAX_SIZE 200; // depends on spreading factor and frequency used
eptak 2:ac824f095591 10
eptak 2:ac824f095591 11 CayenneLPP Payload(MAX_SIZE);
eptak 2:ac824f095591 12
eptak 3:a65959c9e3b9 13 float celsius = -4.1;
eptak 2:ac824f095591 14 float accel[] = {1.234, -1.234, 0};
eptak 2:ac824f095591 15 float rh = 30;
eptak 3:a65959c9e3b9 16 float hpa = 1014.1;
eptak 5:a67d5a7955c7 17 float latitude = 42.3519;
eptak 5:a67d5a7955c7 18 float longitude = -87.9094;
eptak 5:a67d5a7955c7 19 float altitude:10
eptak 3:a65959c9e3b9 20
eptak 3:a65959c9e3b9 21 int size = 0;
eptak 2:ac824f095591 22
eptak 2:ac824f095591 23 Payload.reset();
eptak 3:a65959c9e3b9 24 size = Payload.addTemperature(0, celsius);
eptak 3:a65959c9e3b9 25
eptak 3:a65959c9e3b9 26 if (size == 0) {
eptak 3:a65959c9e3b9 27 // not enough byte left to add the data
eptak 3:a65959c9e3b9 28 }
eptak 3:a65959c9e3b9 29
eptak 3:a65959c9e3b9 30 else {
eptak 3:a65959c9e3b9 31 // add function returned current payload size
eptak 3:a65959c9e3b9 32 }
eptak 3:a65959c9e3b9 33
eptak 3:a65959c9e3b9 34
eptak 2:ac824f095591 35 Payload.addAccelerometer(1, accel[0], accel[1], accel[2]);
eptak 2:ac824f095591 36 Payload.addRelativeHumidity(3, rh);
eptak 3:a65959c9e3b9 37 Payload.addBarometricPressure(4, hpa);
eptak 4:8d32c35e74ad 38 Payload.addGPS(5, latitude, longitude, altitude);
eptak 2:ac824f095591 39
eptak 3:a65959c9e3b9 40 // Call LoRaWAN library to send the frame
eptak 2:ac824f095591 41 LORA_SEND(Payload.getBuffer(), Payload.getSize());
eptak 2:ac824f095591 42 ```