Skip to content

Commit

Permalink
Merge pull request #16 from ElectronicCats/beelan_example
Browse files Browse the repository at this point in the history
Update Beelan example
  • Loading branch information
sabas1080 authored Aug 19, 2020
2 parents 3190093 + f8dbbe5 commit 3caa015
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/BuildLibrary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest # I picked Ubuntu to use shell scripts.

env:
REQUIRED_LIBRARIES: ArduinoJson,Beelan LoRaWAN,SparkFun MPL3115A2 Altitude and Pressure Sensor Breakout,SparkFun HTU21D Humidity and Temperature Sensor Breakout
REQUIRED_LIBRARIES: ArduinoJson,Beelan LoRaWAN

strategy:
matrix:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.pio
.vscode
.vscode
.DS_Store
35 changes: 30 additions & 5 deletions examples/Basic_LoRaWAN_Beelan/Basic_LoRaWAN_Beelan.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
* Distributed as-is; no warranty is given.
*/
#include <lorawan.h>
#include<CayenneLPP.h>

CayenneLPP lpp(51);

//ABP Credentials
const char *devAddr = "00000000";
Expand Down Expand Up @@ -64,13 +67,10 @@ void loop() {
if(millis() - previousMillis > interval) {
previousMillis = millis();

sprintf(myStr, "Counter-%d", counter);
printVariables();

Serial.print("Sending: ");
Serial.println(myStr);

lora.sendUplink(myStr, strlen(myStr), 0);
counter++;
lora.sendUplink((char *)lpp.getBuffer(), lpp.getSize(), 0, 1);
}

recvStatus = lora.readData(outStr);
Expand All @@ -80,4 +80,29 @@ void loop() {

// Check Lora RX
lora.update();
}

void printVariables()
{
lpp.reset();

int humidity = random(0,300);
Serial.print(F(",humidity="));
Serial.print(humidity, 1);
lpp.addRelativeHumidity(3, humidity);

int temp = random(0,200);
Serial.print(F(",tempf="));
Serial.print(temp, 1);
lpp.addTemperature(4, temp);

int pressure = random(0,2000);
Serial.print(F(",pressure="));
Serial.print((pressure/100.0), 2);
lpp.addBarometricPressure(7,(pressure/100.0));

int batt_lvl = random(0,3.3);
Serial.print(F(",batt_lvl="));
Serial.print(batt_lvl, 2);
lpp.addAnalogInput(8, batt_lvl);
}

0 comments on commit 3caa015

Please sign in to comment.