initial commit tp0
This commit is contained in:
parent
1c959ee1d9
commit
2a71c12b13
32
tp0/LoRaReceiver.ino
Normal file
32
tp0/LoRaReceiver.ino
Normal file
@ -0,0 +1,32 @@
|
||||
#include <SPI.h>
|
||||
#include <LoRa.h>
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("LoRa Receiver");
|
||||
|
||||
if (!LoRa.begin(915E6)) {
|
||||
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());
|
||||
}
|
||||
}
|
31
tp0/LoRaSender.ino
Normal file
31
tp0/LoRaSender.ino
Normal file
@ -0,0 +1,31 @@
|
||||
#include <SPI.h>
|
||||
#include <LoRa.h>
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("LoRa Sender");
|
||||
|
||||
if (!LoRa.begin(915E6)) {
|
||||
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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user