initial commit tp0

This commit is contained in:
OMGiTzPomPom 2022-09-08 15:42:03 +02:00
parent 1c959ee1d9
commit 2a71c12b13
3 changed files with 63 additions and 1 deletions

View File

@ -1 +0,0 @@
# TLESIO61---Communication-entre-objets

32
tp0/LoRaReceiver.ino Normal file
View 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
View 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);
}