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); +}