added cayennellp

pull/12/head
Kent Wiliams 2020-03-16 16:28:19 -07:00
rodzic 1f4460998d
commit d6d80548dd
1 zmienionych plików z 14 dodań i 3 usunięć

Wyświetl plik

@ -41,6 +41,7 @@
#include <LPS22HHSensor.h> #include <LPS22HHSensor.h>
#include <STTS751Sensor.h> #include <STTS751Sensor.h>
#include <HTS221Sensor.h> #include <HTS221Sensor.h>
#include <CayenneLPP.h>
#ifdef ARDUINO_SAM_DUE #ifdef ARDUINO_SAM_DUE
#define DEV_I2C Wire1 #define DEV_I2C Wire1
@ -68,7 +69,7 @@ void os_getDevEui(u1_t *buf) { memcpy_P(buf, DEVEUI, 8); }
static const u1_t PROGMEM APPKEY[16] = {FILL_ME_IN}; static const u1_t PROGMEM APPKEY[16] = {FILL_ME_IN};
void os_getDevKey(u1_t *buf) { memcpy_P(buf, APPKEY, 16); } void os_getDevKey(u1_t *buf) { memcpy_P(buf, APPKEY, 16); }
static uint8_t mydata[] = "Hello, world!"; CayenneLPP lpp(51);
static osjob_t sendjob; static osjob_t sendjob;
// Schedule TX every this many seconds (might become longer due to duty // Schedule TX every this many seconds (might become longer due to duty
@ -263,7 +264,17 @@ void readSensors() {
AccGyr->Get_X_Axes(accelerometer); AccGyr->Get_X_Axes(accelerometer);
AccGyr->Get_G_Axes(gyroscope); AccGyr->Get_G_Axes(gyroscope);
// Output data. // Clear Payload
lpp.reset();
// Pack Packload
lpp.addTemperature(1, temperature);
lpp.addRelativeHumidity(2, humidity);
lpp.addBarometricPressure(3, pressure);
lpp.addAccelerometer(4, accelerometer[0], accelerometer[1], accelerometer[2]);
lpp.addGyrometer(5, gyroscope[0], gyroscope[1], gyroscope[2]);
// Debug Print Data
Serial.print("| Hum[%]: "); Serial.print("| Hum[%]: ");
Serial.print(humidity, 2); Serial.print(humidity, 2);
Serial.print(" | Temp[C]: "); Serial.print(" | Temp[C]: ");
@ -291,7 +302,7 @@ void do_send(osjob_t *j) {
} else { } else {
readSensors(); readSensors();
// Prepare upstream data transmission at the next possible time. // Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, mydata, sizeof(mydata) - 1, 0); LMIC_setTxData2(1, lpp.getBuffer(), lpp.getSize(), 0);
Serial.println(F("Packet queued")); Serial.println(F("Packet queued"));
} }
// Next TX is scheduled after TX_COMPLETE event. // Next TX is scheduled after TX_COMPLETE event.