Skip to content

Instantly share code, notes, and snippets.

@penpencool
Created April 28, 2018 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save penpencool/79cc8fe2cd7eea5d6029a50c86475d44 to your computer and use it in GitHub Desktop.
Save penpencool/79cc8fe2cd7eea5d6029a50c86475d44 to your computer and use it in GitHub Desktop.
ArduinoLoRa
#include <SPI.h>
#include <LoRa.h>
// Example By ArduinoAll
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("LoRa Receiver");
if (!LoRa.begin(433E6)) {
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()) {
Serial.print((char)LoRa.read());
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
}
}
#include <SPI.h>
#include <LoRa.h>
// Example By ArduinoAll
int counter = 0;
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("LoRa Sender");
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
}
void loop() {
Serial.print("Sending packet: ");
Serial.println(counter);
// send packet
LoRa.beginPacket();
LoRa.print("hello ");
LoRa.print(counter);
LoRa.endPacket();
counter++;
delay(5000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment