Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <loraid.h>
  2.  
  3. long interval = 10000;    // 10 s interval to send message
  4. long previousMillis = 0;  // will store last time message sent
  5. unsigned int counter = 0;     // message counter
  6.  
  7. void setup() {
  8.   // Setup loraid access
  9.   lora.init();
  10.  
  11.   // Set LoRaWAN Class. CLASS_A and CLASS_C are available
  12.   lora.setDeviceClass(CLASS_A);
  13.  
  14.   // Set Data Rate
  15.     // SF12 to SF7 available. Also SF7_250 for 250KHz variant  
  16.   lora.setDataRate(SF12);
  17.  
  18.   // Put your Antares account key and Lora.id device address here
  19.   lora.setAccessKey("b4e89ce2436b9d90:202c7b14b849c084");
  20.   lora.setDeviceId("712ce6f2");
  21. }
  22.  
  23. void loop() {
  24.   // put your main code here, to run in a loop:
  25.   char outStr[255];
  26.   int recvStatus = 0;
  27.  
  28.   unsigned long currentMillis = millis();
  29.  
  30.   // Check if more than 10 seconds
  31.     if(currentMillis - previousMillis > interval) {
  32.     previousMillis = currentMillis;
  33.  
  34.         String data = "Hello world! " + String(counter);  
  35.     lora.sendToAntares(data);
  36.     counter++;
  37.   }
  38.  
  39.   recvStatus = lora.readData(outStr);
  40.   if(recvStatus) {
  41.     Serial.println(outStr);
  42.   }
  43.  
  44.   // Check Lora RX
  45.   lora.update();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement