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


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.


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.


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.


LoRa Aliance

Libstock LoRa RF Library 2015

GITHub Source for LoRa RF Library 2015

Products mentioned

, , , , , , , ,

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