tp1
This commit is contained in:
parent
40a6a58e72
commit
f2806ccce1
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);
|
||||||
|
}
|
24
tp1/python/Lecture_portcom.py
Normal file
24
tp1/python/Lecture_portcom.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import serial as s
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
ser=s.Serial()
|
||||||
|
ser.baudrate = 9600
|
||||||
|
ser.port = "COM5"
|
||||||
|
ser.timeout=10
|
||||||
|
|
||||||
|
ser.open()
|
||||||
|
f=open('datas.csv','w')
|
||||||
|
|
||||||
|
for uwu in range(0,10) :
|
||||||
|
x = ser.readline()
|
||||||
|
t = datetime.datetime.now()
|
||||||
|
|
||||||
|
f.write(str(x))
|
||||||
|
f.write("; ")
|
||||||
|
f.write(str(t))
|
||||||
|
f.write("\n")
|
||||||
|
print("Écriture de la ligne " + str(uwu+1))
|
||||||
|
|
||||||
|
print("écriture finie")
|
||||||
|
f.close()
|
||||||
|
ser.close()
|
10
tp1/python/datas.csv
Normal file
10
tp1/python/datas.csv
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
b'Applejack is best pony ! Received by Pauline Srifi ~\r\n'; 2022-09-15 16:16:06.340607
|
||||||
|
b'h%l\xcc\x12.\x9d\x14\x13Pauline temp is 115\xc2\xb0.\r\n'; 2022-09-15 16:16:09.275030
|
||||||
|
b'Pauline temp is 121\xc2\xb0.\r\n'; 2022-09-15 16:16:14.333684
|
||||||
|
b'Pauline temp is -1\xc2\xb0.\r\n'; 2022-09-15 16:16:19.390743
|
||||||
|
b'Pauline temp is -43\xc2\xb0.\r\n'; 2022-09-15 16:16:24.449501
|
||||||
|
b'Pauline temp is -26\xc2\xb0.\r\n'; 2022-09-15 16:16:29.507680
|
||||||
|
b'Pauline temp is -24\xc2\xb0.\r\n'; 2022-09-15 16:16:34.566655
|
||||||
|
b'Pauline temp is 112\xc2\xb0.\r\n'; 2022-09-15 16:16:39.624938
|
||||||
|
b'Pauline temp is -50\xc2\xb0.\r\n'; 2022-09-15 16:16:44.681967
|
||||||
|
b'Pauline temp is -2\xc2\xb0.\r\n'; 2022-09-15 16:16:49.740181
|
|
Loading…
x
Reference in New Issue
Block a user