Advertisement
hwthinker

LORAUNO_Receiver-433MHz

Feb 10th, 2019
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //modified lora library by Sandeep Mistry for Wemos TTGO LORA
  2. // lora receiver modified by hwthinker
  3. // setting board pro mini 5V
  4. // serial port must open
  5.  
  6. #include <SPI.h>
  7. #include <LoRa.h>
  8.  
  9. // GPIO5  -- SX1278's SCK
  10. // GPIO19 -- SX1278's MISO
  11. // GPIO27 -- SX1278's MOSI
  12. // GPIO18 -- SX1278's CS
  13. // GPIO14 -- SX1278's RESET
  14. // GPIO26 -- SX1278's IRQ(Interrupt Request)
  15.  
  16. #define SS      10
  17. #define RST     9
  18. #define DI0     2
  19. #define BAND    433E6  
  20.  
  21. void setup() {
  22.   Serial.begin(115200);
  23.   while (!Serial); //if just the the basic function, must connect to a computer
  24.   delay(1000);
  25.  
  26.   Serial.println("LoRa Receiver");
  27.  
  28. //  SPI.begin(5,19,27,18);
  29.   LoRa.setPins(SS,RST,DI0);
  30.  
  31.   if (!LoRa.begin(BAND)) {
  32.     Serial.println("Starting LoRa failed!");
  33.     while (1);
  34.   }
  35. }
  36.  
  37. void loop() {
  38.   // try to parse packet
  39.   int packetSize = LoRa.parsePacket();
  40.   if (packetSize) {
  41. // received a packet
  42.     Serial.print("Received packet '");
  43.  
  44.     // read packet
  45.     while (LoRa.available()) {
  46.       Serial.print((char)LoRa.read());
  47.     }
  48.  
  49.     // print RSSI of packet
  50.     Serial.print("' with RSSI ");
  51.     Serial.println(LoRa.packetRssi());
  52.   }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement