Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement