fbpx

This time I want to tell you about some tests I have been doing with LoRa wireless technology. In particular, I am interested in LoRa tests without line of sight, to see their behavior in real situations in an urban environment.

I have long been an enthusiastic promoter of this technology, which promises to change the IoT landscape around the world. If you are interested in learning about LoRaWAN, here are some articles on the subject.

What is LoRa technology and why is it important for IoT

LoRa – Features and Applications

How is the LoRaWAN architecture

LoraWAN – BW, SF and bitrate

TTN's LoRa gateway for your community

Earlier this year I attended The Things Network conference in Amsterdam, the Netherlands. It was an amazing experience and I came back with the conviction that we have a lot to do in Latin America to be able to take advantage of the advantages and opportunities that this technology offers.

the things network conference

On this occasion I have used only the LoRa physical layer, that is, I did not implement a LoRaWAN solution, with a gateway and others. My intention was simply to do some range tests inside the building complex where I live.

The configuration

What I did was communicate two nodes, one working as a transmitter and one as a receiver. 

The hardware I used for this test was the ESP32 based TTGO LoRa V2 development board. This board offers LoRa, Bluetooth and WiFi communication, making it very convenient for prototyping.

nodo lora ttgo

I did the programming of the nodes in the following way:

  • The transmitter sends a message indicating the transmission number. The transmission occurs every one second, although any other sending frequency can be used.
  • On the receiver display you can see the power received in the message and the message number. In this way you can know if you are receiving all the messages or if you miss some.

The code

To do these tests I used code borrowed from Random Nerd Tutorials.

I leave here below the code for both nodes and I invite you to carry out your own tests. 

//Libraries for LoRa #include #include //Libraries for OLED Display #include #include #include //define the pins used by the LoRa transceiver module #define SCK 5 #define MISO 19 #define MOSI 27 #define SS 18 #define RST 14 #define DIO0 26 //433E6 for Asia //866E6 for Europe //915E6 for North America #define BAND 866E6 // OLED pins #define OLED_SDA 21 #define OLED_SCL 22 #define OLED_RST 16 #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels Adafruit_SSD1306 display(SCREEN_WIDTH, &SCREEN_HEIGHT); StringLoRaData; void setup() { //reset OLED display via software pinMode(OLED_RST, OUTPUT); digitalWrite(OLED_RST, LOW); delay(20); digitalWrite(OLED_RST, HIGH); //initialize OLED Wire.begin(OLED_SDA, OLED_SCL); if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C for 128x32 Serial.println(F("SSD1306 allocation failed")); for(;;); // Don't proceed, loop forever } display.clearDisplay(); display.setTextColor(WHITE); display.setTextSize(2); display.setCursor(0,0); display.print("LORA RECEIVER "); display.display(); //initialize Serial Monitor Serial.begin(115200); Serial.println("LoRa Receiver Test"); //SPI LoRa pins SPI.begin(SCK, MISO, MOSI, SS); //setup LoRa transceiver module LoRa.setPins(SS, RST, DIO0); if (!LoRa.begin(BAND)) { Serial.println("Starting LoRa failed!"); while(1); } Serial.println("LoRa Initializing OK!"); display.setCursor(0,10); display.println("LoRa Initializing OK!"); display.display(); } void loop() { //try to parse packet int packetSize = LoRa.parsePacket(); if (packetSize) { //received a packet Serial.print("Received packet "); //read packet while (LoRa.available()) { LoRaData = LoRa.readString(); Serial.print(LoRaData); } //print RSSI of packet int rssi = LoRa.packetRssi(); Serial.print(" with RSSI "); Serial.println(rssi); // Display information display.clearDisplay(); display.setCursor(0,0); // display.print("LORA RECEIVER"); // display.setCursor(0,20); // display.print("Received packet:"); display.setCursor(0,10); display.print(LoRaData); display.setCursor(0,30); display.print("RSSI:"); display.setCursor(30,50); display.print(rssi); display.display(); } }
//Libraries for LoRa #include #include //Libraries for OLED Display #include #include #include //define the pins used by the LoRa transceiver module #define SCK 5 #define MISO 19 #define MOSI 27 #define SS 18 #define RST 14 #define DIO0 26 //433E6 for Asia //866E6 for Europe //915E6 for North America #define BAND 866E6 // OLED pins #define OLED_SDA 21 #define OLED_SCL 22 #define OLED_RST 16 #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels //packet counter int counter = 0; Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST); void setup() { //reset OLED display via software pinMode(OLED_RST, OUTPUT); digitalWrite(OLED_RST, LOW); delay(20); digitalWrite(OLED_RST, HIGH); //initialize OLED Wire.begin(OLED_SDA, OLED_SCL); if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C for 128x32 Serial.println(F("SSD1306 allocation failed")); for(;;); // Don't proceed, loop forever } display.clearDisplay(); display.setTextColor(WHITE); display.setTextSize(2); display.setCursor(0,5); display.print("LORA SENDER "); display.display(); //initialize Serial Monitor Serial.begin(115200); Serial.println("LoRa Sender Test"); //SPI LoRa pins SPI.begin(SCK, MISO, MOSI, SS); //setup LoRa transceiver module LoRa.setPins(SS, RST, DIO0); if (!LoRa.begin(BAND)) { Serial.println("Starting LoRa failed!"); while(1); } Serial.println("LoRa Initializing OK!"); display.setCursor(0,20); display.print("LoRa Initializing OK!"); display.display(); delay(2000); } void loop() { Serial.print("Sending packet: "); Serial.println(counter); //Send LoRa packet to receiver LoRa.beginPacket(); LoRa.print("hello "); LoRa.print(counter); LoRa.endPacket(); display.clearDisplay(); display.setCursor(0,5); //display.println("LORA SENDER"); display.setCursor(0,20); display.setTextSize(2); display.print("LoRa packet sent."); display.setCursor(0,10); display.print("Counter:"); display.setCursor(80,50); display.print(counter); display.display(); counter++; delay(10000); }

It is important to modify some values of the code so that it adapts to the board you are going to use, since they change pin numbers, frequencies, etc.

Tests

With this configuration I left the transmitter node on the balcony of my apartment and went for a walk with the receiver. And now I was able to do the LoRa tests without line of sight.

During the course of my walk I could see that the connection was maintained even without having line of sight at all, which on the other hand was expected. In fact, walking between the buildings the reception was quite good and I got coverage for most of the way, except for very specific points.

In the figure below I show two specific points where I got -115 dBm power with no message loss. Something remarkable considering that the test itself was quite poor and was using very low gain antennas at both nodes.

conclusion

LoRa technology offers great opportunities in the implementation of IoT systems, due to its long range and low consumption. This allows nodes to be easily deployed, without relying on other communication infrastructure. 

In addition, the very low power consumption means that the nodes can be powered by batteries, avoiding the complication of an electrical installation. Small solar screens or some other energy harvesting technique can also be used (energy harvesting).

Finally, it must be taken into account that these tests were made to evaluate the reliability of connecting sensors in the surroundings. The maximum possible connection distance was not evaluated nor was the hardware configuration maximized for the latter.

I invite you to leave your doubts and comments below ;).

Categories: IoT Platforms

8 Comments

Marcelo · 7 September, 2020 at 8:48 PM

Hello Rodrigo, interesting test. According to what I see in the code, you did not use the frequency intended for Argentina. Does the module support it? In your opinion, it is useful to use it in a serious application or only for testing. Greetings Marcelo

    IoT Consulting · 8 September, 2020 at 11:32 AM

    Hello, Marcelo
    This module supports 866 and 915 bands. You can easily change that in the code. However, for non-LoRaWAN applications, any band can be used because neither band requires a license.
    Cheers!.
    Rodrigo.

yilber · 9 September, 2020 at 9:32 PM

Excellent

Paul Costan · 5 May, 2021 at 12:38 AM

What nodes do you recommend using in Argentina today? The idea is to have 1 node transmitting every 5 blocks (you would understand that I need a gateway instead of a common receiving node there, right?)

Thanks.

    IoT Consulting · 5 May, 2021 at 10:21 AM

    Pablo:
    I don't know what your project is, but nodes are not meant to serve other nodes. For that it is better to install gateways in strategic places. With a single gateway on a tower you can cover a much larger area, depending on the topography of the place. In very dense areas, with many buildings, it is possible to have ranges of 500 meters without line of sight. In places with low buildings, several kms. And in the open field, you can go up to 20/30 km with the right configuration.

    Cheers!.

      IoT Consulting · 5 May, 2021 at 10:22 AM

      In addition, the issue of antennas must be taken into account. The nodes have very low gain antennas, while the gateways come with higher gain antennas, which offer a much greater range of coverage.

Paul Costan · 11 May, 2021 at 9:00 PM

Thanks for the reply,
My idea is to have 1 node with 3 sensors transmitting mqtt (Lora), then another node 1 hectare away with another 3 sensors transmitting mqtt (Lora) and all this that reaches a Google Cloud-style server. I understand that as a hub I need this Gateway, right?
In this case, what types of devices are used to transmit through mqtt and Lora to the gateway.

    IoT Consulting · 11 May, 2021 at 9:09 PM

    Pablo:
    You will need an exterior gateway to communicate the nodes. The nodes do not send MQTT, but use the LoRa frame to pack and transmit the data.
    The gateway can then use LoRaWAN via a network server or send the messages to an MQTT server (not using LoRaWAN).
    For your case, a gateway with one or two channels may be enough.
    If you are going to use LoRaWAN, in the event that you use a downlink, I recommend a gateway with at least two channels. For these types of gateways, with LoRaWAN, you are going to have to use ABP.
    If you are going to use LoRa and send the packets over MQTT, you can buy a single channel gateway to send the data over the uplink.

    Greetings.

Leave a Reply

Avatar placeholder

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

en_USEnglish
%d bloggers like this: