Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arduino demo source code for LoRa "SENDER"
#1
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);
}
before use this code, need to install LoRa SX1278 arduino library firstly.
   
Reply


Messages In This Thread
Arduino demo source code for LoRa "SENDER" - by admin - 07-21-2024, 05:10 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)