From 2a71c12b130f2978a645de2f1c685e5cd3b43bb2 Mon Sep 17 00:00:00 2001 From: OMGiTzPomPom Date: Thu, 8 Sep 2022 15:42:03 +0200 Subject: [PATCH] initial commit tp0 --- README.md | 1 - tp0/LoRaReceiver.ino | 32 ++++++++++++++++++++++++++++++++ tp0/LoRaSender.ino | 31 +++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) delete mode 100644 README.md create mode 100644 tp0/LoRaReceiver.ino create mode 100644 tp0/LoRaSender.ino diff --git a/README.md b/README.md deleted file mode 100644 index 785d534..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# TLESIO61---Communication-entre-objets diff --git a/tp0/LoRaReceiver.ino b/tp0/LoRaReceiver.ino new file mode 100644 index 0000000..ccbb453 --- /dev/null +++ b/tp0/LoRaReceiver.ino @@ -0,0 +1,32 @@ +#include +#include + +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()); + } +} diff --git a/tp0/LoRaSender.ino b/tp0/LoRaSender.ino new file mode 100644 index 0000000..a252ee5 --- /dev/null +++ b/tp0/LoRaSender.ino @@ -0,0 +1,31 @@ +#include +#include + +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); +}