Advertisement
pleasedontcode

LoRaWAN Receiver

Jul 30th, 2024
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 0.56 KB | Source Code | 0 0
  1. #include <SPI.h>
  2. #include <LoRa.h>
  3.  
  4. void setup() {
  5.   Serial.begin(9600);
  6.   while (!Serial);
  7.  
  8.   Serial.println("LoRa Receiver");
  9.  
  10.   if (!LoRa.begin(915E6)) {
  11.     Serial.println("Starting LoRa failed!");
  12.     while (1);
  13.   }
  14. }
  15.  
  16. void loop() {
  17.   // Try to parse packet
  18.   int packetSize = LoRa.parsePacket();
  19.   if (packetSize) {
  20.     // Read packet
  21.     String received = "";
  22.     while (LoRa.available()) {
  23.       received += (char)LoRa.read();
  24.     }
  25.  
  26.     // Print received packet
  27.     Serial.print("Received packet: ");
  28.     Serial.println(received);
  29.   }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement