SHARE
TWEET

Untitled

a guest Sep 21st, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SPI.h>
  2. #include <LoRa.h>
  3.  
  4. #define SCK     5    // GPIO5  -- SX1278's SCK
  5. #define MISO    19   // GPIO19 -- SX1278's MISO
  6. #define MOSI    27   // GPIO27 -- SX1278's MOSI
  7. #define SS      18   // GPIO18 -- SX1278's CS
  8. #define RST     14   // GPIO14 -- SX1278's RESET
  9. #define DI0     26   // GPIO26 -- SX1278's IRQ(Interrupt Request)
  10.  
  11. void setup() {
  12.   Serial.begin(9600);
  13.   while (!Serial);
  14.  
  15.   Serial.println("LoRa Receiver");
  16.  
  17.   SPI.begin(SCK, MISO, MOSI, SS);
  18.   LoRa.setPins(SS, RST, DI0);
  19.  
  20.   if (!LoRa.begin(866E6)) {
  21.     Serial.println("Starting LoRa failed!");
  22.     while (1);
  23.   }
  24.   Serial.println("LoRa started!");
  25. }
  26.  
  27. void loop() {
  28.   // try to parse packet
  29.   int packetSize = LoRa.parsePacket();
  30.   if (packetSize) {
  31.     // received a packet
  32.     Serial.print("Received packet '");
  33.  
  34.     // read packet
  35.     while (LoRa.available()) {
  36.       Serial.print((char)LoRa.read());
  37.     }
  38.  
  39.     // print RSSI of packet
  40.     Serial.print("' with RSSI ");
  41.     Serial.println(LoRa.packetRssi());
  42.   }
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top