Advertisement
Guest User

lora_rx

a guest
Aug 19th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <LoRa.h>
  3. //define the pins used by the transceiver module
  4. #define ss 5
  5. #define rst 14
  6. #define dio0 2
  7. int counter = 0;
  8. void setup() {
  9. //initialize Serial Monitor
  10. Serial.begin(115200);
  11. while (!Serial);
  12. delay(500);
  13. Serial.println("LoRa Receiver");
  14. //setup LoRa transceiver module
  15. LoRa.setPins(ss, rst, dio0);
  16. //replace the LoRa.begin(---E-) argument with your location's frequency
  17. //433E6 for Asia
  18. //866E6 for Europe
  19. //915E6 for North America
  20. while (!LoRa.begin(433E6)) {
  21. Serial.println(".");
  22. delay(500);
  23. }
  24. // Change sync word (0xF3) to match the receiver
  25. // The sync word assures you don't get LoRa messages from other LoRa transceivers
  26. // ranges from 0-0xFF
  27. LoRa.setSyncWord(0xF3);
  28. Serial.println("LoRa Initializing OK!");
  29. }
  30. void loop() {
  31. // try to parse packet
  32. int packetSize = LoRa.parsePacket();
  33. if (packetSize) {
  34. // received a packet
  35. Serial.print("Received packet '");
  36. // read packet
  37. while (LoRa.available()) {
  38. String LoRaData = LoRa.readString();
  39. Serial.print(LoRaData);
  40. }
  41. // print RSSI of packet
  42. Serial.print("' with RSSI ");
  43. Serial.println(LoRa.packetRssi());
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement