Implementing GPS and PB
This commit is contained in:
parent
f96fbd421a
commit
cd39a64bed
47
sender.ino
47
sender.ino
|
@ -1,47 +0,0 @@
|
|||
#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