IOT

How to use Reyax RYLR890 LoRa Module with Arduino

In this project, we will learn how to use the Reyax RYLR890 LoRa Module with Arduino. The Lora long-range modem, which offers ultra-long range spread spectrum communication and good interference immunity while minimizing current consumption, is a feature of the RYLR890/RYLR896 transceiver module. We previously learned about the SPI pins used to connect the LoRa Module LR1276/SX1276 to the STM32 Microcontroller. Today, we’ll learn about the UART LoRa Module, which only requires 4 pins to work with any microcontroller.

The communication range of the Lora Module RYLR890/RYLR896 is up to 10-15 km. The best noise-reduction technology was used in its design. It is simple to connect the LoRa Module to an Arduino board, an ESP8266, an ESP32, or an STM32 microcontroller. The module uses extremely little power, at 43mA during transmission and 16.5mA during the reception. The power is further reduced to 0.5uA when the module is put into sleep mode.

In this tutorial, we will first create a basic Arduino LoRa RYLR890 Transmitter/Receiver Circuit and perform a point-to-point communication, such as wirelessly charging an LED’s brightness. In the second illustration, we will wirelessly communicate sensor data from transmitter to receiver. The BME280 sensor, which measures environmental temperature, humidity, pressure, and altitude, is the sensor we’ll be using.

Hardware Required

  • Arduino Nano
  • Reyax RYLR890/RYLR896
  • Potentiometer-10k
  • 5mm LED Any Color
  • BME280 Barometric Pressure Sensor
  • Resistor-10K,4.7K
  • Connecting wire
  • Breadboard

Reyax LoRa RYLR890/RYLR896

The LoRa Module RYLR890/RYLR896 from Reyax Technologies is based on Semtech LoRa Chip SX1276 and STM32L151C8T6 microcontroller. The SX1276 Chips operate on frequency 868/915Mhz & are interfaced to STM32L151C8T6 via SPI Pins.

RYLR890 RYLR896

The UART pins on Arduino can be used to quickly interface the Reyax RYLR890/RYLR896 LoRa module. A list of AT Commands is available that can be used to carry out any task, such as sending or receiving data or placing the device in sleep mode. This Technical AT can teach you more about the AT Commands.

Features & Specifications

  • Semtech SX1276 Chip
  • Excellent blocking immunity
  • Operating Voltage: 2.8V – 3.3V
  • Low Current Consumption (43mA in Transmission, 16.5 in receiving, 0.5uA in Sleep Mode)
  • Communication Range: 4.5km Typical & 15km Maximum
  • High RF sensitivity: -148dBm
  • Control easily by AT commands
  • 127 dB Dynamic Range RSSI
  • Small PCB integrated antenna
  • AES128 Data encryption

Pinouts

RYLR896 Pinout

Interfacing RYLR890/RYLR896 LoRa Module with Arduino

Let’s now study how to connect an Arduino board to an RYLR890 or RYLR896 LoRa module. In this first example, we’ll build a transmitter and a receiver circuit and use a potentiometer to wirelessly adjust an LED’s brightness.

Transmitter Circuit

Reyax RYLR890 Arduino

The potentiometer in the transmitter circuit is connected to Arduino’s A0 Pin to provide varying analog voltage as it is rotated. Since the Arduino digital pins may produce 5V while the LoRa module runs at 3.3V, we require a voltage divider network for the UART ports. As a result, a voltage divider network that reduces 5V logic voltage to almost 3.4V uses a 4.7K & 10K resistor. Put the circuit together as the illustration indicates.

Receiver Circuit

RYLR890 Arduino LED

The led in the receiver circuit is wired to the Arduino’s D5 pin, and its brightness may be changed while the transmitter is sending a signal.

Reyax RYLR896 Transmitter Receiver

Source Code/Program

The transmitter and receiver circuit code is provided below. After building the transmitter and receiver circuits, you can upload the code to them.

Transmitter Code

#include <SoftwareSerial.h>

SoftwareSerial lora(2,3);

int pot = A0;

void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
lora.begin(115200);
pinMode(pot, INPUT);
}

void loop()
{
int val = map(analogRead(pot),0,1024,0,255);
Serial.println(val);
String potval = String(val);
String cmd = “AT+SEND=0,”+String(potval.length()) +”,”+ String(val)+”\r”;
//Serial.println(“AT+SEND=0,3,val”);
lora.println(cmd);
while(lora.available()){
Serial.write(lora.read());
}
Serial.println();
Serial.println(cmd);
delay(50);
}

Receiver Code

#include <SoftwareSerial.h>

SoftwareSerial lora(2,3);

int LED = 5;
//String inString = “”; // string to hold input
int val = 0;

void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
lora.begin(115200);
pinMode(LED, OUTPUT);

}

void loop()
{
//char ch;
String inString;
while (lora.available())
{
if(lora.available()){
inString += String(char(lora.read()));
}
}
if(inString.length()>0)
{
//Serial.println(inString);
String potval;
potval= inString.substring(9,12);
Serial.println(potval);
analogWrite(LED,potval.toInt());
}
//delay(100);
}

After the code is uploaded to both the microcontroller board, you can start testing the entire circuit. On the transmitter side, you need to rotate the potentiometer so that the receiver LED Brightness will increase or decrease.

Send Sensor Data wirelessly with LoRa RYLR890/RYLR896 & Arduino

In the second example, we will wirelessly transmit data from a BME280 barometric pressure sensor to a LoRa receiver. Measurements of temperature, pressure, humidity, and altitude are made via the BME280 barometric pressure sensor.

Transmitter Circuit

The BME280 sensor is attached to the Arduino’s I2C pins in the transmitter circuit. Since the Arduino digital pins may produce 5V while the LoRa module runs at 3.3V, we require a voltage divider network for the UART ports. As a result, a voltage divider network that reduces 5V logic voltage to almost 3.4V uses a 4.7K & 10K resistor. Put the circuit together as the illustration indicates.

Receiver Circuit

Arduino Reyax RYLR890 Connection

The receiver circuit has nothing except the LoRa Module connected to the UART pin of the Arduino

Source Code/Program

The transmitter and receiver circuit code is provided below. You can upload the code to both the transmitter and receiver circuits after assembling the full circuit in accordance with the circuit schematic.

Transmitter Code

#include <SoftwareSerial.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

SoftwareSerial lora(2,3);

#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme;

void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
lora.begin(115200);
if (!bme.begin(0x76))
{
Serial.println(“Could not find a valid BME280 sensor, check wiring!”);
while (1);
}
}

void loop()
{
float temperature = bme.readTemperature();
float pressure = bme.readPressure() / 100.0F;
float altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
float humidity = bme.readHumidity();

Serial.print(F(“Temperature = “));
Serial.print(temperature);
Serial.println(F(“*C”));

Serial.print(F(“Pressure = “));
Serial.print(pressure);
Serial.println(F(“hPa”));

Serial.print(F(“Approx. Altitude = “));
Serial.print(altitude);
Serial.println(F(“m”));

Serial.print(F(“Humidity = “));
Serial.print(humidity);
Serial.println(F(“%”));

String temp = String(temperature);
String pres = String(pressure);
String alt = String(altitude);
String hum = String(humidity);

String values = String(temp)+”,”+ String(pres)+”,”+ String(alt)+”,”+ String(hum);
String cmd = “AT+SEND=0,”+String(values.length())+”,”+values;
lora.println(cmd);

while(lora.available())
{
Serial.write(lora.read());
}
Serial.println();
Serial.println(cmd);
delay(5000);
}

Receiver Code

#include <SoftwareSerial.h>
SoftwareSerial lora(2,3);

void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
lora.begin(115200);

}

void loop()
{
String inString;
while (lora.available())
{
if(lora.available()){
inString += String(char(lora.read()));
}
}
if(inString.length()>0)
{
Serial.println(inString);
inString.remove(0);
}

}

You may access the Serial Monitor for both the transmitter and receiver components once the code has been published. The BME280 sensor data will be read by the sender/transmitter circuit and wirelessly transmitted to the receiver. The data will be received by the receiver, and it will appear on the Serial Monitor with the RSSI signal.

So here is how Reyax LoRa RYLR890 or RYLR896 & Arduino can communicate point to point.

Conclusion:

I hope all of you understand how to use Reyax RYLR890 LoRa Module with Arduino. We MATHA ELECTRONICS will be back soon with more informative blogs.

Leave a Reply

Your email address will not be published.