AT Settings: INR=9600 ; NetworkID =6( just has to be the same for both) Network Address= 0 or 1;915 MHz
Arduino Uno + LoRa Reyax RYLR896 890 | Communication 2 Arduino board using Reyax Lora RYLR890 896
Transmitting Program(Blinking LED)
#include <SoftwareSerial.h>
SoftwareSerial ReyaxLoRa(5, 4); //--> RX, TX
int data_length;
String data;
int Stat_LED = HIGH;
void setup() {
Serial.begin(9600);
ReyaxLoRa.begin(9600);
delay(100);
ReyaxLoRa.print("AT\r\n");
Serial.print("AT\r\n");
}
void loop() {
Stat_LED = !Stat_LED;
data = String(Stat_LED);//this can be replaced with a sensor value
data_length = data.length();
String mymessage;
mymessage = mymessage + "AT+SEND=0" + "," + data_length + "," + data + "\r\n";
ReyaxLoRa.print(mymessage); //--> Send Data
Serial.print("Send Data : ");
Serial.print(mymessage);
delay(2000);
}
Receiver Program- Blinking LED
//Reyax RYLR896 890 LoRa Receive Data
#include <SoftwareSerial.h>
SoftwareSerial ReyaxLoRa(5, 4); //--> RX, TX
String myString;
char data;
#define LED 3 //--> LED Pin
void setup() {
Serial.begin(9600);
ReyaxLoRa.begin(9600);
pinMode(LED, OUTPUT);
delay(100);
ReyaxLoRa.print("AT\r\n");
Serial.print("AT\r\n");
}
void loop() {
if (ReyaxLoRa.available() > 0 ) {
myString = ReyaxLoRa.readString();
Serial.print("Receive Data : ");
Serial.print(myString);
Serial.println("Data Processing");
String addr = getValue(myString, ',', 0); //--> address
String dtl = getValue(myString, ',', 1); //--> data length
String dt = getValue(myString, ',', 2); //--> data
String rssi = getValue(myString, ',', 3); //--> RSSI
String snr = getValue(myString, ',', 4); //--> SNR
Serial.print("Address : ");
Serial.println(addr);
Serial.print("Data length : ");
Serial.println(dtl);
Serial.print("Data : ");
Serial.println(dt); // dt can be a sensor value
Serial.print("RSSI : ");
Serial.println(rssi);
Serial.print("SNR : ");
Serial.println(snr);
//----------------------------------------Conditions to turn on or turn off the LED
if (dt == "1") digitalWrite(LED, HIGH);
if (dt == "0") digitalWrite(LED, LOW);
}
}
String getValue(String data, char separator, int index) {
int found = 0;
int strIndex[] = { 0, -1 };
int maxIndex = data.length() - 1;
for (int i = 0; i <= maxIndex && found <= index; i++) {
if (data.charAt(i) == separator || i == maxIndex) {
found++;
strIndex[0] = strIndex[1] + 1;
strIndex[1] = (i == maxIndex) ? i+1 : i;
}
}
return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}
🌐 GitHub Repository - 🔗 https://github.com/make2explore/Reyax-LoRa-Module-RYLR998-Review
🌐 Hackster Blog - 🔗 https://www.hackster.io/make2explore/greenhouse-monitoring-system-lora-iot-fb6907
🌐 Instructable Blog - 🔗 https://www.instructables.com/Greenhouse-Monitoring-System/
Sending Data:
Void setup() {
Serial.begin(115200); // Initialize serial communication with the Reyax module
Serial.println("AT+ADDRESS=1"); // Set the module address to 1
delay(100);
Serial.println("AT+NETWORKID=5"); // Set the network ID to 5
delay(100);
Serial.println("AT+PARAMETER=12,7,1"); // Set the RF parameters
delay(100);
}
void loop() {
String message = "Hello, LoRa!";
int address = 2; // Destination address
int length = message.length();
// Construct the command
String command = "AT+SEND=" + String(address) + "," + String(length) + "," + message;
// Send the command
Serial.println(command);
delay(5000); // Wait 5 seconds before sending the next message
}
Reading data:
void loop() {
if (Serial.available() > 0) {
String receivedData = Serial.readStringUntil('\n'); // Read the incoming message
// Print the received data
Serial.print("Received: ");
Serial.println(receivedData);
// You can add additional parsing logic here if needed
}
}