Skip to content

Instantly share code, notes, and snippets.

@sabas1080
Created April 20, 2018 02:19
Show Gist options
  • Save sabas1080/b65299bac722df0ab57f01cc3bf6a3d7 to your computer and use it in GitHub Desktop.
Save sabas1080/b65299bac722df0ab57f01cc3bf6a3d7 to your computer and use it in GitHub Desktop.
Example for RAK811 with Lora Sender and library LoRa
/*
Example for RAK811 with Lora Sender and library LoRa https://github.com/sandeepmistry/arduino-LoRa
*/
#include <SPI.h>
#include <LoRa.h>
int counter = 0;
void setup() {
Serial.begin(9600);
while (!Serial);
SPI.setMISO(RADIO_MISO_PORT);
SPI.setMOSI(RADIO_MOSI_PORT);
SPI.setSCLK(RADIO_SCLK_PORT);
SPI.setSSEL(RADIO_NSS_PORT);
LoRa.setPins(RADIO_NSS_PORT, RADIO_RESET_PORT, RADIO_DIO_0_PORT);
Serial.println("LoRa Sender");
if (!LoRa.begin(915E6)) {
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment