#include "LoRa.h"
#include "SPI.h"
//esp32 ss-5 rst-14 di0-2
//nodemcu ss-15 rst-16 di0-2
#define ss 15
#define rst 16
#define dio0 2
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());
}
}
TRANSMITTER CIRCUIT :
LORA TRANSMITTER CODE :
#include "LoRa.h"
#include "SPI.h"
//esp32 ss-5 rst-14 di0-2
//nodemcu ss-15 rst-16 di0-2
#define ss 5
#define rst 14
#define dio0 2
int counter = 0;
void setup()
{
Serial.begin(115200);
while (!Serial);
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("hello from Agni sat");
LoRa.print(counter);
LoRa.endPacket();
counter++;
delay(1000);
}
No comments:
Write comments