You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#include <SPI.h>
|
|
|
|
#include <LoRa.h>
|
|
|
|
|
|
|
|
typedef struct{ // frame structure
|
|
|
|
uint16_t ID = 1025; // ID
|
|
|
|
uint16_t TS = 0; // TimeStamp
|
|
|
|
uint16_t DT = 0; // Data Type
|
|
|
|
uint16_t D1 = 0; // DATA 1
|
|
|
|
uint16_t D2 = 0; // DATA 2
|
|
|
|
uint16_t D3 = 0; // DATA 3
|
|
|
|
}trame;
|
|
|
|
|
|
|
|
trame message;
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
Serial.begin(9600);
|
|
|
|
while (!Serial);
|
|
|
|
|
|
|
|
Serial.println("LoRa Sender");
|
|
|
|
|
|
|
|
message.ID = 0x0007;
|
|
|
|
message.TS = 0x0001;
|
|
|
|
message.DT = 0x0001;
|
|
|
|
message.D1 = 0x0002;
|
|
|
|
message.D2 = 0x0003;
|
|
|
|
message.D3 = 0x0004;
|
|
|
|
|
|
|
|
if (!LoRa.begin(868E6)) {
|
|
|
|
Serial.println("Starting LoRa failed!");
|
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
Serial.print("Sending packet: ");
|
|
|
|
|
|
|
|
// send packet
|
|
|
|
LoRa.beginPacket();
|
|
|
|
LoRa.write((uint8_t)(message.ID >> 8));
|
|
|
|
LoRa.write((uint8_t)message.ID);
|
|
|
|
LoRa.endPacket();
|
|
|
|
|
|
|
|
delay(3000);
|
|
|
|
}
|