52 lines
818 B
C++
52 lines
818 B
C++
#include <SPI.h>
|
|
#include <LoRa.h>
|
|
|
|
// The dragino shield
|
|
#define PIN_SS 10
|
|
#define PIN_RESET 9
|
|
#define PIN_DIO0 2
|
|
|
|
// Wemos
|
|
//#define PIN_SS 15
|
|
//#define PIN_RESET 4
|
|
//#define PIN_DIO0 5
|
|
|
|
// Custom: The smart greenhouse device
|
|
//#define PIN_SS 10
|
|
//#define PIN_RESET -1
|
|
//#define PIN_DIO0 2
|
|
|
|
|
|
// Channel 0
|
|
#define FREQUENCY 868100000
|
|
|
|
|
|
int counter = 0;
|
|
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
while (!Serial);
|
|
|
|
Serial.println("LoRa Sender");
|
|
|
|
LoRa.setPins(PIN_SS, PIN_RESET, PIN_DIO0);
|
|
if (!LoRa.begin(FREQUENCY)) {
|
|
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);
|
|
}
|