07-21-2024, 05:10 AM
Code:
#include <LoRa.h>
#include <SPI.h>
#define ss 41
#define rst 2
#define dio0 40
int counter = 0;
void setup()
{
SPI.begin(42, 43, 44, 41); //SPI.begin(PIN_SPI_SCK, PIN_SPI_MISO, PIN_SPI_MOSI, -1); last one is SS not used, use -1
Serial.begin(115200);
Serial.println("LoRa Sender");
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()
{
Serial.print("Sending packet: ");
Serial.println(counter);
LoRa.beginPacket(); //Send LoRa packet to receiver
LoRa.print("KinCony LoRa");
LoRa.print(counter);
LoRa.endPacket();
counter++;
delay(2000);
}