Arduino LoRa Ra-02 Range Test using Different types of Antennas
Table of Contents
Arduino LoRa Range Test:
Arduino LoRa Range Test using Different types of Antennas- In my previous article, I made this Arduino LoRa development board for the prototyping and testing my arduino based projects. I have already tested the relays, SSD1306 Oled display module, and the 5 volt Buzzer. But I didn’t check the Ai-thinker 433Mhz Ra-02 LoRa transceiver module. I have designed this board using the Altium Designer software.
So, for this test, I made one more development board and now I can easily perform my tests. Because, now, I can use one of these development boards as the transmitter, and the other one as the receiver. It’s not only about the checking if these LoRa modules are working are not, but its specifically about testing the communication range using different types of Antennas. And we will see which LoRa antennas are going to give us maximum communication range. So, without any further delay, let’s get started!!!
Amazon Links:
Arduino Nano USB-C Type (Recommended)
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
For the demonstration purposes, I am using one board as the transmitter and the other board as the receiver. On the transmitter side, I have connected the DHT21 Temperature and Humditiy sensor. So, I will be sending its value wirelessly to the receiver side where the temperature and humidity values will be printed on the Oled display module. If you want to make the same exact development boards then you can read my article on Arduino development board. Or if you want to use the readymade LoRa modules then you can follow the circuit diagrams given below.
Arduino LoRa TX side:
The LoRa connections on the Transmitter and receiver side are exactly the same. The VCC of the LoRa module is connected with the 3.3V of the Arduino nano. The MISO Pin of the LoRa module is connected with the Arduino’s pin 12. The MOSI pin is connected with the Arduino’s pin 11. The SCLK pin of the LoRa module is connected with the Arduino’s pin 13. The NSS pin is connected with the Arduino’s pin 10 and the ground pin of the LoRa module is connected with the Arduino’s GND.
Now to connect DHT21 sensor with Arduino nano:
- Connect the signal pin of the DHT21 with the D3 pin of the Arduino nano.
- Connect the VCC pin of the DHT21 with the 3.3V of the Arduino nano. And
- Connect the ground pin of the DHT21 with the ground of the Arduino nano.
Arduino LoRa Receiver Side:
- Connect VCC of the OLED with 3.3V of the Arduino nano.
- Connect ground of the OLED with ground of the Arduino nano.
- Connect the SDA pin of the OLED with A4 pin of the Arduino nano.
- Connect the SCL pin of the OLED with A5 pin of the Arduino nano.
Now, let’s go ahead and take a look at different types of LoRa Antennas.
Download the Required Libraries:
LoRa Tx side Program:
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
/* Transmitter, nano */ #include <SPI.h> // include libraries #include <Wire.h> #include <LoRa.h> #include "DHT.h" #define DHTPIN 3 #define DHTTYPE DHT21 //DHT 21 (AM2301) DHT dht(DHTPIN, DHTTYPE); //Initialize DHT sensor for normal 16mhz Arduino float temp; // to save the temperature value int hum; //humidity value String outgoing; // outgoing message byte msgCount = 0; // count of outgoing messages byte localAddress = 0xBB; // address of this device byte destination = 0xFF; // destination to send to long lastSendTime = 0; // last send time int interval = 50; // interval between sends String Mymessage = ""; void setup() { Serial.begin(9600); // initialize serial dht.begin(); if (!LoRa.begin(433E6)) { // initialize ratio at 915 MHz Serial.println("LoRa init failed. Check your connections."); while (true); // if failed, do nothing } Serial.println("LoRa init succeeded."); } void loop() { if (millis() - lastSendTime > interval) { hum = dht.readHumidity(); temp = dht.readTemperature(); Mymessage = Mymessage+ temp + "," + hum; sendMessage(Mymessage); delay(100); Mymessage = ""; //Serial.println("Sending " + message); lastSendTime = millis(); // timestamp the message interval = random(50) + 100; } } void sendMessage(String outgoing) { LoRa.beginPacket(); // start packet LoRa.write(destination); // add destination address LoRa.write(localAddress); // add sender address LoRa.write(msgCount); // add message ID LoRa.write(outgoing.length()); // add payload length LoRa.print(outgoing); // add payload LoRa.endPacket(); // finish packet and send it msgCount++; // increment message ID } |
LoRa Rx Side Program:
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
/* Receiver, Nano */ #include <SPI.h> // include libraries #include <LoRa.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> float temp; int hum; String outgoing; // outgoing message byte msgCount = 0; // count of outgoing messages byte localAddress = 0xFF; // address of this device byte destination = 0xBB; // destination to send to long lastSendTime = 0; // last send time int interval = 50; // interval between sends #define SCREEN_WIDTH 128 // ORelay display width, in pixels #define SCREEN_HEIGHT 64 // ORelay display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) #define ORelay_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, ORelay_RESET); void setup() { Serial.begin(9600); // initialize serial; if (!LoRa.begin(433E6)) { // initialize ratio at 915 MHz Serial.println("LoRa init failed. Check your connections."); while (true); // if failed, do nothing } Serial.println("LoRa init succeeded."); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); delay(2000); display.clearDisplay(); display.setTextColor(WHITE); } void loop() { onReceive(LoRa.parsePacket()); } void onReceive(int packetSize) { if (packetSize == 0) return; // if there's no packet, return // read packet header bytes: int recipient = LoRa.read(); // recipient address byte sender = LoRa.read(); // sender address byte incomingMsgId = LoRa.read(); // incoming msg ID byte incomingLength = LoRa.read(); // incoming msg length String incoming = ""; while (LoRa.available()) { incoming += (char)LoRa.read(); } if (incomingLength != incoming.length()) { // check length for error // Serial.println("error: message length does not match length"); ; return; // skip rest of function } // if the recipient isn't this device or broadcast, if (recipient != localAddress && recipient != 0xFF) { //Serial.println("This message is not for me."); ; return; // skip rest of function } // if message is for this device, or broadcast, print details: // Serial.println("Received from: 0x" + String(sender, HEX)); // Serial.println("Sent to: 0x" + String(recipient, HEX)); //Serial.println("Message ID: " + String(incomingMsgId)); // Serial.println("Message length: " + String(incomingLength)); //Serial.println("Message: " + incoming); //Serial.println("RSSI: " + String(LoRa.packetRssi())); //Serial.println("Snr: " + String(LoRa.packetSnr())); //Serial.println(); String q = getValue(incoming, ',', 0); String r = getValue(incoming, ',', 1); temp = q.toFloat();// tempreature value hum = r.toInt();// humidity value Serial.println(hum); display.clearDisplay(); display.setCursor(10,20); display.setTextSize(2); //display.print("C: "); display.print(temp); display.print((char)247); display.print("C"); display.setCursor(10,45); display.setTextSize(2); display.print("H:"+String(hum)+"%"); display.display(); delay(1000); incoming = ""; } 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]) : ""; } |
Altium Designer + Altium 365 + Octopart:
Altium 365 lets you hold the fastest design reviews ever. Share your designs from anywhere and with anyone with a single click. it’s easy, leave a comment tagging your teammate and they’ll instantly receive an email with a link to the design. Anyone you invite can open the design using a web browser. Using the browser interface, you’re able to comment, markup, cross probe, inspect, and more. Comments are attached directly to the project, making them viewable within Altium designer as well as through the browser interface. Design, share, and manufacture, all in the same space with nothing extra to install or configure. Connect to the platform directly from Altium Designer without changing how you already design electronics. Altium 365 requires no additional licenses and comes included with your subscription plan.
Get real-time component insights as you design with Octopart built into Altium 365. Octopart is the fastest search engine for electronic parts and gives you the most up-to-date part data like specs, datasheets, cad models, and how much the part costs at different amounts etc. Right in the design environment so you can focus on your designs. Start with Altium Designer and Activate Altium 365. Search for electronic parts on Octopart.
Types of LoRa Antennas:
Along with 433Mhz Ra-02 LoRa modules I also got these three different types of 433Mhz antennas from the Ai-Thinker.
First let’s start with the 433Mhz Flexible PCB Antenna.
433Mhz Flexible PCB Antenna for LoRa:
These are 433Mhz FPC 27x17mm Omni directional flexible PCB Antennas.
Its gain is 2 DBi.
The Antenna efficiency is between 35-80%.
Voltage Standing Wave Ratio ( VSWR ) : < 1.8
Antenna interface is Ipex1
Operating Temperature is around 70 degrees Celsius.
433Mhz LoRa Whip Antenna:
This is 433MHz LoRa Whip Antenna.
Its gain is 5 DBi.
Voltage Standing Wave Ratio ( VSWR ) : < 1.5
Input Impedance is 50 ohms.
Polarization is vertical.
Weight is 20 grams.
Connector type is SMA-JW
433Mhz suction cup LoRa Antenna:
This is the 433Mhz suction cup LoRa Antenna. It’s a high gainsucker antenna.
Its gain is 5dBi
Voltage Standing Wave Ratio ( VSWR ) : < 1.5
Resistance is 50 ohms
Interface is SMA-JW
Which LoRa Antenna is best?
The choice of the best LoRa antenna depends on various factors such as the specific application, environment, and requirements. Let’s take a closer look at each option you mentioned:
Flexible PCB Antenna: Flexible PCB antennas are compact and lightweight, making them suitable for space-constrained devices. They can be integrated directly onto the circuit board, eliminating the need for external components. They offer reasonable performance and are cost-effective. However, their range and coverage might be limited compared to other types of antennas. Flexible PCB antennas are commonly used in wearable devices, small sensors, and IoT applications.
Whip Antenna: Whip antennas are traditional, omnidirectional antennas that consist of a straight metal rod or wire. They are easy to install and provide good coverage in all directions. Whip antennas generally have better range and signal penetration capabilities compared to flexible PCB antennas. However, they are more physically visible and may be susceptible to damage or vandalism due to their external placement. Whip antennas are commonly used in outdoor applications, gateways, and situations where maximum coverage is desired.
Suction Cup Antenna: Suction cup antennas are a specific type of whip antenna designed for temporary or portable installations. They usually have a suction cup base that allows them to be attached to a flat surface like a window or a car windshield. Suction cup antennas provide flexibility in placement and are easy to remove and reposition. However, their performance might be slightly compromised compared to fixed whip antennas due to the suction cup attachment mechanism.
In summary, there is no universally “best” LoRa antenna as it depends on the specific use case and requirements. If space is limited and cost-effectiveness is a priority, a flexible PCB antenna might be suitable. If maximum coverage and range are essential, a whip antenna would be a better choice. Suction cup antennas are ideal for temporary or portable installations where flexibility in placement is required. It is important to consider factors such as size, range, coverage, and installation requirements when selecting the most suitable LoRa antenna for a particular application.
Let’s go ahead and find out which LoRa antenna is going to perform well during Out of sight range test and during Line of sight range test.
So, first let’s go ahead and start with the 433Mhz LoRa Flexible PCB Antennas.
433Mhz LoRa Flexible PCB Antenna Test:
I have powered up the receiver side using a 12V adaptor and the transmitter side using my created 4S Lithium Ion Battery. I can use different voltage sources because the onboard 5V and 3A power supply can accept wide range of input voltages between 7 and 28 volts. The reason I am using a battery pack on the transmitter side is because I want to make it portable so that my brother can freely move around while testing the communication range.
Anyway, you can already see the Temperature and humidity values on the receiver side.
You can see as I apply heat to the sensor the temperature value on the Oled display module increased to 25.90 degrees Celsius. So, its working.
LoRa Flexible PCB Out of Sight Range Test:
During this first test, the receiver side is going to be inside the room and I am going to ask my brother to take the transmitter outside. I just want to check if the signals are powerful enough to penetrate through walls and different obstacles.
During this test, I was asking my brother about his location to find out from how far these modules could communicate. While he was moving around in the street outside, I could see the LEDs blinking on the receiver side. Then, at one point, the communication stopped.
When I checked it on Google Maps, the distance was 243 meters. This is the distance when both LoRa modules are out of sight and there are walls and obstacles in between, as you can see in the image.
433Mhz LoRa Whip Out of Sight Range Test:
Next, I told my brother to connect the 433Mhz LoRa Whip Antenna and I also connected the same LoRa Whip Antenna on the receiver side. And as you can see, I am not able to receive the data. So, I told my brother to come back.
And then at one point I started receiving the data.
I checked the distance on Google map and it was 91 meters. Seriously, I was thinking the Whip antenna’s would perform well than the small Flexible PCB antennas.
433Mhz suction cup LoRa Antenna Out of Sight Range Test:
Next, I connected this 433Mhz suction cup LoRa Antenna. As I have got only one antenna, so I connected it on the receiver side. While on the transmitter side the Whip antenna is connected. You can see I can receive the temperature and humidity values. So, I told my brother to go in the opposite direction. And then at point the LEDs stopped blinking and there was no communication.
I checked the distance on google map and it was 118 meters. Because of the Suction Cup antenna on the receiver side the communication distance improved a little.
Anyway, I told my brother to connect the Flexible PCB Antenna on the transmitter side, while on the receiver side I am using the Suction Cup Antenna. Anyway, I told my brother to start walking in the opposite direction. Then at one point LEDs stopped blinking and there was no communication.
So, I checked the distance on Google map and it was 305 meters. This is so far the maximum out of sight range.
Flexible PCB antennas are great and when used with Suction cup antenna the communication range can be further increased. So, the Flexible PCB Antenna and the Suction Cup antenna gave me the maximum out of sight communication distance.
LoRa Line of sight range tests using different Antennas:
Next, we are going to perform line of sight test on these different types of LoRa antennas.
433Mhz LoRa Whip Line of Sight Range Test:
I came to this open location to perform the line of site test. My brother is right there on top of the mountain with the transmitter. I started with the 433MHz LoRa whip Antenna’s. Let’s see from how far these modules can communicate when in line of sight.
I checked the distance on Google map and the distance was 432 meters.
LoRa Flexible PCB Line of Sight Test:
Next, we connected the LoRa Flexible PCB antenna’s on the transmitter and receiver side. And as you can see its working.
433Mhz suction cup LoRa Antenna Line of Sight Range Test:
I performed the same test for the 433Mhz Suction Cup LoRa Antenna and it was working.
This is the maximum distance I can check over here. So, I am going back to home and let’s see if I can receive the temperature and humidity values over there.
Maximum Line of sight distance check:
So, I came back to my home and right now I am on the roof and from here I can see the mountain. And I can also see my brother, he is right on the top.
The mountain is 955 meters away from my house. I confirmed this distance on the Google Map.
Anyway, First we started with the LoRa whip antennas and as you can see i am able to receive the Temperature and humidity values.
Its working great and I am sure it will cover around 1.5km.
Next, we connected the Flexible PCB antennas on the transmitter and receiver side, and it worked superbly. During the out of sight range test, it almost covered twice the distance of the LoRa whip antennas. And I think the flexible PCB antennas may cover around 2.5 to 3 Km or may be even more.
Next, on the receiver side, I connected the suction cup antenna while on the receiver side the Flexible PCB antenna is still connected. And as you can see I can receive the values. If you remember during the out of sight range test, the suction cup antenna improved the communication range. So, I think it may cover more than 4 kilometers, if it’s used with the Flexible PCB Antenna.
The Ai-thinker 433Mhz LoRa Ra-02 transceiver modules when used with different types of 433Mhz LoRa antennas. You can send and receive the data over such a long distance around 1.5 to 5Km.
Even if its two kilometers, still it covers such a long area, not only my village but also the neighbouring villages. Now, within this area, I can send OFF Grid wireless text messages, I can monitor different types of sensors, I can control different types of loads, I can track different things, I can use it for the security purposes, and so on. So, that’s all for now.
Watch Video Tutorial: