Initial commit
This commit is contained in:
commit
738a86c40c
47
sender.ino
Normal file
47
sender.ino
Normal file
@ -0,0 +1,47 @@
|
||||
#include <SPI.h>
|
||||
#include <LoRa.h>
|
||||
|
||||
int counter = 0;
|
||||
unsigned long previousMillis = 0;
|
||||
const long interval = 20000;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("LoRa Transceiver");
|
||||
|
||||
if (!LoRa.begin(915E6)) {
|
||||
Serial.println("Starting LoRa failed!");
|
||||
while (1);
|
||||
}
|
||||
LoRa.setSpreadingFactor(7);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
int packetSize = LoRa.parsePacket();
|
||||
if (packetSize) {
|
||||
Serial.print("Received Packet: ");
|
||||
while (LoRa.available()) {
|
||||
Serial.print((char) LoRa.read());
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
unsigned long currentMillis = millis();
|
||||
if (currentMillis - previousMillis >= interval) {
|
||||
previousMillis = currentMillis;
|
||||
Serial.print("Sending packet: ");
|
||||
Serial.println(counter);
|
||||
|
||||
// send packet
|
||||
|
||||
LoRa.beginPacket();
|
||||
LoRa.print(counter);
|
||||
LoRa.print("|hello");
|
||||
LoRa.endPacket();
|
||||
|
||||
counter++;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user