tp1
This commit is contained in:
31
tp1/arduino/LoRaReceiver/LoRaReceiver.ino
Normal file
31
tp1/arduino/LoRaReceiver/LoRaReceiver.ino
Normal file
@ -0,0 +1,31 @@
|
||||
#include <SPI.h>
|
||||
#include <LoRa.h>
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("Applejack is best pony ! Received by Pauline Srifi ~");
|
||||
|
||||
if (!LoRa.begin(864E6)) {
|
||||
Serial.println("Starting LoRa failed!");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// try to parse packet
|
||||
int packetSize = LoRa.parsePacket();
|
||||
if (packetSize) {
|
||||
// received a packet
|
||||
|
||||
// read packet
|
||||
while (LoRa.available()) {
|
||||
Serial.print((char)LoRa.read());
|
||||
}
|
||||
|
||||
// print RSSI of packet
|
||||
//Serial.print("' with RSSI ");
|
||||
//Serial.println(LoRa.packetRssi());
|
||||
}
|
||||
}
|
35
tp1/arduino/LoRaSender/LoRaSender.ino
Normal file
35
tp1/arduino/LoRaSender/LoRaSender.ino
Normal file
@ -0,0 +1,35 @@
|
||||
#include <SPI.h>
|
||||
#include <LoRa.h>
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("Applejack is best pony ! Send by Pauline Srifi ~");
|
||||
|
||||
if (!LoRa.begin(864E6)) {
|
||||
Serial.println("Starting LoRa failed!");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
int generateRandomTemp() { //-50 to 150
|
||||
int r = (rand() % (150 - (-50) + 1)) + (-50);
|
||||
return r;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int temp = generateRandomTemp();
|
||||
// send packet
|
||||
LoRa.beginPacket();
|
||||
LoRa.print("Pauline temp is ");
|
||||
LoRa.print(temp);
|
||||
LoRa.println("°.");
|
||||
LoRa.endPacket();
|
||||
|
||||
counter++;
|
||||
|
||||
delay(5000);
|
||||
}
|
Reference in New Issue
Block a user