Smart Home Automation Forum
[Arduino IDE demo source code for KC868-A6]--#10-SX1278-receiver_code - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-A6 (https://www.kincony.com/forum/forumdisplay.php?fid=22)
+--- Thread: [Arduino IDE demo source code for KC868-A6]--#10-SX1278-receiver_code (/showthread.php?tid=1870)



[Arduino IDE demo source code for KC868-A6]--#10-SX1278-receiver_code - KinCony Support - 04-26-2022

[Arduino IDE demo source code for KC868-A6]--#10-SX1278-receiver_code

Code:
/* SX1278 code for KC868-A6*/
#include <LoRa.h>
#include <SPI.h>

#define ss 5
#define rst 14
#define dio0 21

void setup()
{
  Serial.begin(115200);
  while (!Serial);
  Serial.println("LoRa Receiver");

  LoRa.setPins(ss, rst, dio0);    //setup LoRa transceiver module

  while (!LoRa.begin(433E6))     //433E6 - Asia, 866E6 - Europe, 915E6 - North America
  {
    Serial.println(".");
    delay(500);
  }
  LoRa.setSyncWord(0xA5);
  Serial.println("LoRa Initializing OK!");
}

void loop()
{
  int packetSize = LoRa.parsePacket();    // try to parse packet
  if (packetSize)
  {
   
    Serial.print("Received packet '");

    while (LoRa.available())              // read packet
    {
      String LoRaData = LoRa.readString();
      Serial.print(LoRaData);
    }
    Serial.print("' with RSSI ");         // print RSSI of packet
    Serial.println(LoRa.packetRssi());
  }
}
       
.zip   10.sx1278-receiver.zip (Size: 1,018 bytes / Downloads: 287)