MikroElektronika Learn

LoRa RF click

RF Technologies & IOT

LoRa RF click – solution for IOT developers

4 Feb , 2016  

The Internet of Things is the network of physical objects, devices and other items which are embedded with electronics, software, sensors, and network connectivity, which enables these objects to collect and exchange data.  Allowing objects to be sensed and controlled remotely across existing network infrastructures creates opportunities for more-direct integration. This link between the physical world and computer-based world results in improved efficiency, accuracy and economic benefits.

Long Range Wide Area Network ( LoRaWAN ) is a low power wireless networking protocol designed for low-cost, secure two-way communication with the Internet of Things. Key requirements of Internet of Things such as secure bi-directional communication, mobility, and localization services are achieved by LoRaWAN. This standard also provides seamless interoperability among smart “Things” without the need of complex local installations and gives back the freedom to the user, developer, businesses.

LoRaWAN network architecture is typically constructed in a star-of-stars topology in which gateways is a transparent bridge relaying messages between end-devices and a central network server in the backend. Gateways are connected to the network server via standard IP connections while end-devices use single-hop wireless communication to one or many gateways.

LoRa Wireless Network

All LoRaWAN devices carry out at least the Class A functionality. Devices implementing more than Class A are generally named “higher Class end-devices”.

Description

LoRa RF click board with Microchip’s RN2483 module provides an easy to use, low-power solution for long-range wireless data transmission. The RN2483 module complies with the LoRaWAN Class A protocol specifications. The transceiver can operate in the 433 MHz and 868 MHz frequency bands. Coverage of more than 15 km at suburban and more than 5 km at urban area and low power consumption make it suitable for battery-powered, simple long-range sensor applications with external host MCU. The RN2483 Transceiver module features LoRa Technology RF modulation provides long-range spread spectrum communication with high interference immunity. Using the LoRa modulation technology, RN2483 can meet a receiver sensitivity of -148 dBm.

Setup

Packages, library, documentation, and example for LoRa RF click board can be downloaded from Libstock or Github. Once you have installed the library it is ready to use and here we going to explain how you can use it in your projects.

[irp posts=”102″]

The first thing we need to do is include LoRa RF library into our search path.  This is easily done by selecting Project / Edit / Add search path. Also the LoRa RF reset pin is declared as an external dependency, so we must define those pins dependent on the location on the board. Lastly we need to include all required headers into our project.

Initializing the library requires a UART that the LoRa RF is attached.  This peripheral performs the communication between UART and library itself. Settings for the UART is initialized with LoRa default parameters shown in the example. Baud rate and other parameters are a required match to the radio for proper communication. The library was designed to work in a non blocking way, avoidance of blocking functions like UARTx_Read()  in MikroC is recommended.

While communication can be achieved with polling,  a function based on the UART interrupt is much more reliable. Received data is forwarded to lora_rf_rx_isr( char rx_input ) function within the ISR. Each platform, either it be PIC, ARM, AVR, etc will require the UART interrupt enabled as well as any other global interrupts.  Your code might not be an exact match to the example if you are not using an PIC32 MCU.

Since ISR routines are not part of normal program execution, we add them to the end of our program to better keep the separation between sequential code and ISRs.

Calling of the  lora_rf_init() function that starts the library and communication with the module must be done right after system_init().  In this example we will also use the extended functionality of the library –  lora_rf_callback function to monitor complete responses from the module. A function pointer is required that has exactly same return value and parameters to pass to the lora_rf_callback(func) . This function will be called each time we receive a complete response from the radio or when a timeout occurs. The arguments passed will contain a complete response / data from the module. Inside the body of the   get_response() we will use this parameter with UART_Write_Text() to send the whole response to the other UART peripheral, so we can easy follow responses from the module on PC.

It is very important to initialize the UART to be used with the radio and then the lora_init before any other UART initialization.

Callback function also can be useful to implement log writing but any editing of the parameter should be avoided – if you want to edit the response data the best solution is to copy content to some other variable declared in global space or main function body. The optionally created variable should be big enough to contain MAX_RSP_SIZE + MAX_DATA_SIZE of bytes because that is the maximum response size that can be received. 

The main worker function responsible for most of the processing is  lora_rf_process() and must be placed inside an infinite loop.

Our program is now ready for implementation of any logic needed. The example on video shows implementation of a Thermo 3 click board, reading temperature, and transmitting the data to another node. In this tutorial we will do something simplified by sending a message from one node to another.

Keep in mind that this is a demonstration of LoRa RF peer-to-peer which is not a conventional or supported protocol. For a proper LoRaWAN communication, we should go deeper into the LoRaWAN protocol rules.  Typical communication of course requires a gateway. There exists a tremendous amount of documentation on the Internet on how to build / purchase your own gateway. A benefit to building your own gateway is the detailed information you would gain about the protocol and types of communication.

Implementation od LoRa click on TX / RX Nodes

For this example we will make the simple demonstration of communication between the two modules without any user interaction to make this example more simple for understanding. Difference between TX and RX Nodes will be only in two lines of code inside the body of main function so both examples are provided and you have to remove comments depend on what side you are using.

After the power up host on TX side will send message string without any knowledge about receive side. Receiver on the other side will except the message after the power up.  If we take a closer look to the documentation you will notice that no radio communication can be done before pausing the MAC stack. We will also set the watchdog timer to infinite – just to be sure that our communication is not interrupted by a watchdog timeout. Zero as the first argument in lora_rf_rx() means that radio will be in continuous reception mode.

Note that messages can have only hex digits converted to string – so every two characters represent one byte of data. For proper testing user should first power up the receiver side and after receiver power up turn on TX node. After every function execution we will see response from LoRa RF click board on UART B port of our Fusion board.

That’s all – enjoy the RF in the air.

Summary

The Internet of Things is happening now. It promises to offer a revolutionary, fully connected “smart” world as the relationships between objects, their environment, and people become more tightly intertwined. LoRaWAN is one of very bests solutions for battery powered sensor devices with external MCU and LoRa RF click is excelent choice for startup. Usage of our library can save you a lot of time.

References:

LoRa Aliance

Libstock LoRa RF Library 2015

GITHub Source for LoRa RF Library 2015

Products mentioned

, , , , , , , ,

By  
Firmware developer in MikroElektronika with a passion for telemetry in the field of IoT. Low level is for the true modern day warriors.



16 Responses

  1. Zoran Roncevic says:

    Hello,

    I made some test with click LoRa boards, and everything work well inside one room. I test communication between two LoRa click board. One board send simple data and second receieve it. Both LoRa has attached antenna.

    But, boards must be very close (range less than 10 meters)! Same problem reported from other developers from Pancevo and Germany.

    Zoran Roncevic
    Sprint NT, Novi Sad

    • Milos Vidojevic says:

      Hello Zoran,
      We performed testing inside the building through at least 4 concrete walls and 100 meters. Results were successful. Can you tell me the revision of the board that you using and have you used antennas specified for the 868 or 433 MHz bands?

      Milos

      • Zoran Roncevic says:

        Solved! Problem was with antennas and connectors. I used wrong antennas with female SMA connector. I bought GSM antennas as you suggested with male connectors and it works. Thank your support.

  2. Leonardo says:

    Hello. The LoRa works only in Europe or I can use it here in South America? Thanks.

    • Richard Lowe says:

      LoRa uses a unlicensed frequency that in most parts of the world is completely open and free. You might want to check with your local laws, but as for where it will work, anywhere.

  3. Mitko Tolev says:

    I try to make test with LoRa RF click module. The test is done with Terminal Emulator with connecting trough MAX232. Power select was put on 5V. On power on module send message “RN2483 0.9.5 Mar 24 2015 14:15:33”. When I try to send commands there is no response. When I make inspect by signal testinig I find out that chip TXB0106 does not translate RXD signal.
    What can I do with module in next step?

    • Milos Vidojevic says:

      Hello Mitko,
      It’s unusual that voltage translator works fine only for TXD. Do you sending the “\r\n” ( carriage return and line feed ) characters at the end of message?

  4. Mitko Tolev says:

    Yes, the carriage return and line feed was send.
    The signal was traced with multi channel oscilloscope. One channel was connected to pin 13 from TXB0106, another one was connected to pin 4 from TXB0106. When signal with command was send to RXD, the signal was present on pin 13, but the signal was not present on pin 4. The conclusion is that TXB0106 was faulty.
    The LoRa RF click module was bought from shop Loging-Electronics in Skopje on 06 July 2016. The question is to change only TXB0106 or to return back to MicroElektronika for replacement.

    Best regards,
    Mitko Tolev

    • Milos Vidojevic says:

      That is definitely problem with TXB0106. Check “Help Desk” link on our home page and open a ticket for replacement, our support team will inform you what to do next and how to replace faulty click board. You can also add this conversation as a reference.

      Regards,
      Milos

  5. pipesif says:

    Hi to All,
    sorry but i’m new in “lora systems” i have a stupid and simple question, it is possible to use LoraClick (with mikroC lib) as a client of a Gateway like this “http://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=dv164140-2” ?

    if not, how can i connect many loraRF click in a “concentrator”

    Regard

    • Milos Vidojevic says:

      RN2483 and RN2903 are class A devices. For gateway you will need class C device. With this ones you can perform P2P communication without gateway.
      Best Regards, Milos

      • Pipesif says:

        Thanks Milos, for your reply,
        but if I wanted to use 5 or 10 rfclick to control 5 or 10 sensor how i can concentrate All Readings?
        i can use only P2P communications?

        • Milos Vidojevic says:

          LoRaWAN – this might help you to understand the concept better. Of course, you can implement “P2P like” network in unconventional manner, without usage of MAC layer. For example – if all modules using same frequency, one module ( handled by your application ) can be constantly in reception mode and collect/process data from all other modules.

          Best regards,
          Milos

  6. Alex Gluhak says:

    Hi Milos

    I have recently purchased a pi2 click shield and lora click and aim to run on it on a rasperry pi 3b.

    As far as I know the pinout header on both Pi2 and pi3 are compatible – will it work with a pie 3b?

    Also do you have some example pie code that can interact with the lora click to conifigure the lora module and send/receive messages?

    Many thanks
    Alex

    • Milos Vidojevic says:

      It should work, I haven’t tested but if pinout headers are compatible it will work for sure. If you are planning to use module inside some application you can try to adapt the library but if you want to use the module with some terminal emulator it is enough to pause MAC and transmit/receive message.

      mac pause
      radio tx 48656c6c6f

    • Zoran Roncevic says:

      Alex,

      if Python example works for you, contact me : sprintrz@gmail.com

      Example is tested with Beaglebone (Python) and Mikroelektronika LoRa click

Leave a Reply

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