Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
#include <SPI.h>
#include <LoRa.h>

String contents = "";

void setup() {
  Serial.begin(9600);
  while (!Serial); // wait until serial has started 
  Serial.println("LoRa Receiver");
  if (!LoRa.begin(868E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
}

void loop() {
  // try to parse packet
  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    // received a packet
    Serial.print("Received packet '");
    // read packet
    while (LoRa.available()) {  
      contents += (char)LoRa.read();
    }
    Serial.println(contents);
    // print RSSI of packet
    Serial.print("' with RSSI ");
    Serial.println(LoRa.packetRssi());
    contents = "";
  }
}

Advanced example MKR WAN 1310

...