Created
April 28, 2018 15:24
-
-
Save penpencool/79cc8fe2cd7eea5d6029a50c86475d44 to your computer and use it in GitHub Desktop.
ArduinoLoRa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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