36 lines
597 B
C++
36 lines
597 B
C++
#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);
|
|
}
|