Sensor Monitoring using Lora by Reyax rylr890/rylr896 and Arduino
Table of Contents
Description:
Sensor Monitoring using Lora by Reyax- This is my second tutorial on the Reyax rylr890/rylr896 15km 915Mhz Transceiver module. In this tutorial, you will learn how to make a remote sensor monitoring system using the Reyax rylr890 based Lora module and Arduino Uno. With the help of this project, you can monitor any sensor within a 15km range. For the best understanding, I will be using a Variable resistor as the Sensor, which of course you can replace with any other Sensor you want.
The basic circuit diagram, interfacing, and AT commands are already explained in my previous tutorial. If you are using the rylr890 based Lora module for the first time then I highly recommend first watch that tutorial which covers the extreme basics and then you can resume from here.
Without any further delay let’s get started!!!
Amazon Purchase Links:
Arduino Nano USB-C Type (Recommended)
Reyax rylr890 Lora Transceiver Module:
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
About the Reyax rylr890/rylr896 Lora Transceiver Module:
These are the long-range wireless 915Mhz Radio Frequency LoRa Transceiver Modules by the Reyax Technology. The amazing thing about these modules is that we can change the frequencies of these modules using the AT commands, which I have already explained in my previous tutorial. These modules are designed for long-range communication up to 15 kilometers. Lora transceiver modules can be used in IoT applications, Mobile Equipments, Home security systems, Industrial Monitoring, and control equipment, Car Alarm systems, Robotics, sensors monitoring, and so on.
This transceiver module has the processor which communicates with the Arduino through the Serial communication. So, the exchange of data between the rylr890 and a microcontroller is controlled by this processor.
Reyax rylr890/rylr896 Lora Transceiver Module Specification:
VDD Power Supply:
The minimum voltage is 2.8 volts
The Typical Voltage is 3.3 volts and
The Maximum voltage is 3.6 volts
Using Arduino I can easily power up these transceiver modules using 3.3 volts.
Frequency Range:
Minimum Frequency Range is 820 MHz
Typical Frequency Range is from 868 to 915 MHz
Maximum Frequency range can be up to 1020 MHz
Communication Range:
Typical Range is 4.5KM
Maximum Range is 15KM
Transmit Current:
Typical value is 43 mA
Receive Current:
Typical value is 16.5 mA
Reyax LoRa Module Pinout:
As you can see in the picture above, this transceiver module has a total of 6 pins; which are clearly labeled as VDD, NRST “which is the reset pin active low”. RXD, TXD, pin number 5 is not used, while pin number 6 is the ground.
Reyax LoRa Connection with Arduino:
As you know Arduino is based on the 5v controller while the LoRa transceiver module by the Reyax technology can handle voltages from 2.8 to a maximum of 3.6 volts. The typical voltage is 3.3 volts as explained earlier. From this information we know that this module cannot be directly interfaced with the Arduino for this we need some kind of converter that can convert 5 volts into 3.3 volts. But instead of using the converter we can use a simple voltage divider circuit. As you can see 4.7k and 10k resistors are connected in series which gives me 3.4 volts which is perfect for the Reyax LoRa Transceiver module.
A wire from the middle of these resistors is connected with the RXD pin of the module, the other leg of the 10k resistor is connected with the ground, while the other leg of the 4.7k resistor is connected with the TX of the Arduino. The Rx pin of the Arduino is connected with the TXD pin of the LoRa Module. The ground of the LoRa module is connected with the ground of the Arduino.
The middle leg of the variable resistor or potentiometer is connected with the analog pin A1 of the Arduino; while the other two legs of the variable resistor are connected with the 5 volts and Ground.
PCB layout of the Lora breakout board:
Download the PCB: breakout board for lora
This is the PCB board designed for the Reyax rylr890 Lora Module. I added some extra female headers for connecting sensors, voltage regulators, etc. At the bottom side, I added two female headers for the 5 volts and ground. After I was satisfied with the PCB layout, then I generated the Gerber files and placed an online order on the PCBway website. I have a separate video on this, in which I have explained how to design a PCB and how to place an online order.
These are the PCB boards which I received from the PCBway Company. As you can see the quality is really great and everything is as per the order. The silkscreen is quite clear, the Blue Soldermask looks amazing. I am 100% satisfied with their work. The Gerber files of this PCB can be downloaded from the PCBway website.
Soldering:
For the soldering watch video tutorial given at the end of this article.
This is how it looks after the soldering. All the connections are done as per the circuit diagram.
Sensor Monitoring using Lora Arduino Programming:
In this project two programs are used, one program is written for the transmitter side Arduino and another program is written for the Receiver side Arduino. Let’s first start with the transmitter programming.
Sensor Monitoring using Lora Transmitter Side Programming:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
int vresistor = A1; int vrdata = 0; int data_length; String vresistordata; void setup() { // put your setup code here, to run once: Serial.begin(115200); pinMode(vresistor,INPUT); } void loop() { // put your main code here, to run repeatedly: readresistor(); send_data(vrdata , data_length); delay(100); } void readresistor() { vrdata = analogRead(vresistor); //Serial.println("sensor value:"); //Serial.println(vrdata); // find the length of data vresistordata = String(vrdata); data_length = vresistordata.length(); //Serial.println("data length:"); //Serial.println(data_length); } void send_data(int sensorvalue, int valuelength) { String mymessage; mymessage = mymessage + "AT+SEND=0" + "," + valuelength + "," + sensorvalue + "\r"; Serial.println(mymessage); //Serial.println("AT+SEND=0,6,Hello!\r"); } |
Lora Transmitter side Program Explanation:
This is a very simple program, as you can see no libraries are used. The variable resistor is connected with the Analog pin A1 of the Arduino. Then I defined a variable vrdata of the type integer, this variable will be used to store the value of the variable resistor. data length is a variable of the type integer which will be used to store the total number of digits and finally defined another variable of the type String. This variable will be used to store the complete string message.
In the void setup function, I activated the serial communication, while 115200 is the baud rate. This is the default baud rate of the Reyax Lora. You can easily change this baud rate using the AT commands which I have already explained in my previous tutorial.
The variable resistor is set as the input devices.
Then starts the void loop function; the void loop function consists of only two functions. These are user-defined functions that I created in order to make the program more user-friendly.
Readresistor is a user-defined function, it has no return type and does not take any arguments as the input. The main purpose of this function is to read the variable resistor and store the value in variable vrdata and convert this value into a string value. Using the length function we find the length of the string and store the number in the data_length variable.
Send_data is a user-defined function, it has no return type and takes two arguments as the input, the sensorvalue, and the length.
I defined a variable mymessage which is of the type string.
The AT+SEND commands has three parameters; the address, payload length and the data.
I created a complete message consisting of the AT+SEND command, 0 is the address, and added the payload length and the data which is to be sent. And finally using the serial.println function the complete string message can be sent to the Lora module.
So, that’s all about the Transmitter programming, and now let’s discuss the Receiver programming.
Sensor Monitoring using Lora Receiver Side Programming:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
String myString; String garbage; char data; void setup() { // put your setup code here, to run once: Serial.begin(115200); Serial.print("AT\r\n"); delay(100); } void loop() { // put your main code here, to run repeatedly: if ( Serial.available() > 0 ) { garbage = Serial.readString(); // consists of the +ERR=2 ERROR. myString = Serial.readString(); Serial.println(myString); //Serial.println("Garbage:"); //Serial.println(garbage); } } |
Lora Receiver Side Program Explanation:
I started off by defining the variables of the type string and char.
In the void setup function, I activated the serial communication and select the baud rate.
If the Arduino has received data from the Lora module then simply read the String and print the message on the serial monitor. so, that’s all about the programming. For the practical demonstration and step by step explanation watch video tutorial given below.
I’m having Issues receiving any response from the module when I send any AT commands. I have baudrate set to 115200 but still no response
Use AT+FACTORY to reset the value. Then give at try.
what are connections for the reciever?
I am having problems receiving anything. Nothing shows up. Is the receiver and sender wiring diagram the same?
What is logic level output voltage of ESP32 (ESP32 ESP-WROOM-32 )? 5v or 3.3v?
I have to connect Lora module “REYAX RYLR998” to it, which works with 3.3v only.