Skip to content

Instantly share code, notes, and snippets.

@dwblair
Created September 25, 2020 15:52
Show Gist options
  • Save dwblair/cfe9bfb895d4ad72d88ed91fb76ded47 to your computer and use it in GitHub Desktop.
Save dwblair/cfe9bfb895d4ad72d88ed91fb76ded47 to your computer and use it in GitHub Desktop.
#include <SPI.h>
#include <LoRa.h>
// WIFI_LoRa_32 ports
// GPIO5 -- SX1278's SCK
// GPIO19 -- SX1278's MISO
// GPIO27 -- SX1278's MOSI
// GPIO18 -- SX1278's CS
// GPIO14 -- SX1278's RESET
// GPIO26 -- SX1278's IRQ(Interrupt Request)
#define SS 18
#define RST 14
#define DI0 26
void setup() {
SPI.begin(5, 19, 27, 18);
LoRa.setPins(SS, RST, DI0);
Serial.begin(115200);
while (!Serial);
Serial.println("LoRa Receiver");
if (!LoRa.begin(915E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
}
void loop() {
// try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received packet '");
// read packet
while (LoRa.available()) {
Serial.print((char)LoRa.read());
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment