Arduino ProjectsLORA PROJECTS

Reyax Lora based Multiple Sensors Monitoring using Arduino

Description:

Reyax Lora based Multiple Sensors Monitoring using Arduino- The PCB boards used in this project are sponsored by the PCBway Company, which is one of the most experienced PCB and PCB assembly manufacturer. They create high-quality PCBs at reasonable prices. The Gerber files of the PCB board used in this project can be downloaded from the PCBway official website; you can find a link in the PCB layout section.

Reyax Lora based Multiple Sensors Monitoring- This is my third tutorial on the Reyax rylr890/rylr896 15km 915Mhz transceiver module. In this tutorial, you will learn how to make the Multiple Sensors Monitoring system using Reyax rylr890 based Lora Module and Arduino. This is an advanced level project and explains how to split the entire string message and store the different parameters in different variables.

Reyax Lora based Multiple Sensors

With the help of this project, you can monitor Multiple Sensors within 15km range. In this project, I have used three variable resistors as the sensors, which of course you can replace with any other sensors you want. As the Sensors values are stored in different variables, now you can use if conditions to monitor each sensor individually and then you can control some relays or you can send notification messages, etc.

The basic circuit diagram, programming, interfacing, and AT commands are already explained in my previous two tutorials. If you are using the rylr890 based Lora module for the first time then I highly recommend first watch my previous tutorials which cover the extreme basics and then you can resume from here.


Part 1:

Reyax rylr890/rylr896 LoRa 15km 915MHz RF Transceiver connection and AT commands

Part2:

Reyax rylr890/rylr896 LoRa based Sensor monitoring using Arduino

Without any further delay let’s get started!!!

 Amazon Purchase links :

Reyax rylr890 Lora Transceiver Module:

12v Adaptor:

Arduino Uno

Arduino Nano

Potentiometer:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!


Reyax rylr890/rylr896 Lora Transceiver Module:

Reyax Lora based Multiple Sensors

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 tutorials. These modules are designed for the long-range communication up to 15-kilo meters. 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. Now let’s have look at the specifications.


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

The 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:

Reyax Lora based Multiple Sensors

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 legs of all the variable resistors are connected with the Analog pins A1, A2, and A3. While the other two legs of all the variables are connected with the Arduino’s 5 volts and ground.


PCB layout of the Lora breakout board:

Reyax Lora based Multiple Sensors

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 that 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.

Download Gerber files: 

 Soldering:

For the soldering watch video tutorial given at the end of this article.

Reyax Lora based Multiple Sensors

This is how it looks after the soldering. All the connections are done as per the circuit diagram.

Lora based Multiple Sensors Monitoring Programming:

In this project two programs are used, one program is written for the transmitter side Arduino and the other program is written for the Receiver side, Arduino. Let’s first start with the transmitter programming.

Reyax Lora based Multiple Sensors Transmitter Side Programming:

int vresistor = A1;
int vresistor2 = A2; 
int vresistor3 = A3;
 
int vrdata = 0;
int vrdata2 = 0; 
int vrdata3 = 0; 
 
int data_length; 
String sensorsdata;
void setup() {
  // put your setup code here, to run once:

Serial.begin(115200); 
pinMode(vresistor,INPUT); 
pinMode(vresistor2,INPUT);
pinMode(vresistor3,INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
MultipleSensors();
send_data(sensorsdata , data_length); 
delay(100); 
sensorsdata = ""; 
}

void MultipleSensors()
{
 vrdata = analogRead(vresistor); 
 vrdata2 = analogRead(vresistor2);
 vrdata3 = analogRead(vresistor3);


 sensorsdata = sensorsdata + vrdata +"%"+ vrdata2 + "%" + vrdata3; 
 //Serial.println("sensor value:");
 //Serial.println(vrdata);

// find the length of data
 data_length = sensorsdata.length();
 //Serial.println("data length:"); 
 //Serial.println(data_length);
}

void send_data(String sensorvalue, int valuelength)
{

String mymessage; 
mymessage = mymessage + "AT+SEND=0" + "," + valuelength + "," + sensorvalue + "\r"; 
Serial.println(mymessage); 
  //Serial.println("AT+SEND=0,6,Hello!\r");
}



Transmitter Program Explanation:

This is the same program I used in the second tutorial for monitoring one sensor. For multiple sensors monitoring I did a few changes. I increased the number of Sensors and variables.

Data_length is a variable of the type integer which will be used to store the total number of characters and finally defined another variable of the type String. This variable will be used to store the complete string message consisting of the sensors data.

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 resistors are 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.

MultipleSensors 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 resistors and store the values in variables vrdata, vrdata2, and vrdata3. Then I created a complete string message consisting of the sensors values and used the percent sign as the delimiter, this will help me to split the sensors values on the receiver side. Everything else remains the same as explained in my 2nd tutorial. In the second tutorial I have also explained how the AT+SEND command works and how the parameters are used. So, that’s all about the transmitter side programming. Now let’s discuss the Receiver side programming.


Reyax Lora based Multiple Sensors Receiver Side Programming:

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);

String l = getValue(myString, ',', 0); // address
String m = getValue(myString, ',', 1); // data length
String n = getValue(myString, ',', 2); // data
String o = getValue(myString, ',', 3); //RSSI
String p = getValue(myString, ',', 4); //SNR

Serial.println("Address:"); 
Serial.println(l); 

Serial.println("data length:"); 
Serial.println(m);

Serial.println("Data:"); 
Serial.println(n);

Serial.println("RSSI:"); 
Serial.println(o);

Serial.println("SNR:"); 
Serial.println(p);

// now i am going to split the data string n which consists of the Sensors values
// in this string sensors values are separated by the % sign. 

String q = getValue(n, '%', 0); // sensor1
String r = getValue(n, '%', 1); // sensor2
String s = getValue(n, '%', 2); // sensor3

Serial.println("Sensor1:"); 
Serial.println(q); 

Serial.println("Sensor2:"); 
Serial.println(r); 

Serial.println("Sensor3:"); 
Serial.println(s);
myString = ""; 
}
}


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]) : "";
}


Receiver 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 which is exactly the same as used on the transmitter side.

If the Arduino has received data from the Lora module then simply read the String and print the message on the serial monitor for the debugging purposes. The received string message has a total of 5 parameters address, data length, data, RSSI and SNR. Using the getValue function this string is split using the comma as the delimiter and the parameters are stored in the variables l, m, n, o, and p.

Then using the serial.println function you can send these values to the serial monitor for the debugging purposes.

Now, I am going to split the data string n, which consists of all the Sensors values.

In this string, sensors values are separated by the % sign. So, the sensors values are split and stored in variables q, r, and s. you can use the serial.println function to print these values on the serial monitor to check if you have successfully accessed all the sensors values.

getValue is a user defined function and is used to split the string messages using delimiters.


Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button