Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <LoRa.h>
  3.  
  4. int counter = 0;
  5.  
  6.  
  7. #define SCK 5 // GPIO5 -- SX1278's SCK
  8. #define MISO 19 // GPIO19 -- SX1278's MISO
  9. #define MOSI 27 // GPIO27 -- SX1278's MOSI
  10. #define SS 18 // GPIO18 -- SX1278's CS
  11. #define RST 14 // GPIO14 -- SX1278's RESET
  12. #define DI0 26 // GPIO26 -- SX1278's IRQ(Interrupt Request)
  13.  
  14. void setup() {
  15. Serial.begin(9600);
  16. while (!Serial);
  17.  
  18. Serial.println("LoRa Sender");
  19.  
  20. SPI.begin(SCK, MISO, MOSI, SS);
  21. LoRa.setPins(SS, RST, DI0);
  22.  
  23. if (!LoRa.begin(866E6)) {
  24. Serial.println("Starting LoRa failed!");
  25. while (1);
  26. }
  27. }
  28.  
  29. void loop() {
  30. Serial.print("Sending packet: ");
  31. Serial.println(counter);
  32.  
  33. // send packet
  34. LoRa.beginPacket();
  35. LoRa.print("helloiz ");
  36. LoRa.print(counter);
  37. LoRa.endPacket();
  38.  
  39. counter++;
  40.  
  41. delay(5000);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement