Raspberry Pi Node to Node using IOTIF LoRa

Raspberry Pi Node to Node using IOTIF LoRa


In this blog, we explore the fascinating world of Raspberry Pi and its potential in establishing node-to-node communication using IoTIF LoRa. We delve into the introduction of Raspberry Pi, highlighting its versatility and IoT capabilities. A detailed circuit diagram is provided, guiding readers on how to set up a wireless communication system. Lastly, we conclude with insights into the possibilities and benefits of this project, emphasizing the convenience and efficiency it offers in various IoT applications. Discover how to unlock the potential of Raspberry Pi and LoRa for seamless wireless connectivity!


In this tutorial, we will learn how to connect the LORA Module to Raspberry Pi. We will use the Raspberry Pi and Lora to create a transmitter and receiver for data transmission and reception respectively. The tutorial will provide step-by-step instructions on how to connect the LORA Module to Raspberry Pi. It will explain how to use these components to create a transmitter and receiver for data transmission and reception.

STEP 1(Hardware connection):

Let us setup the Receiver part. Assemble the connection between Raspberry Pi and Lora as shown in the table below:


Lora module 

Raspberry pi

2,3,4,5,6,7,8,9 (8 Pin connector) 

Keypad connector (2,3,4,5,6,7,8,9) 

4 Pin connector (G, 5V, 10, 11) 

4 Pin connector (G, 5V, 10, 11) 


Circuit Diagram: 

STEP 2(Install the library)

For lora communication we need to Install wiringPi library: 

You'll need git. If git is not installed, enter the following into the command line. 

sudo apt-get install git-core 

We highly recommend using Git to download the latest version. To check the version of wiringPi, enter the following command. 

gpio -v 

If you receive an output similar to the following with the Unknown17, you'll want to update WiringPi on a Raspberry Pi 4 or above. 

gpio version: 2.50Copyright (c) 2012-2018 Gordon Henderson 

This is free software with ABSOLUTELY NO WARRANTY. 

For details type: gpio -warranty Raspberry Pi Details:  Type: Unknown17, Revision: 02, Memory: 0MB, Maker: Sony    * Device tree is enabled.    * --> Raspberry Pi 4 Model B Rev 1.2    * This Raspberry Pi supports user-level GPIO access.  

Enter the following to remove the wiringPi and configuration files. 

sudo apt-get purge wiringpi 

Then type the following for the Pi to remove all locations that remember wiringPi. 

hash -r 

As long as you have Git installed, these commands should be all you need to download and install Wiring Pi. 

git clone https://github.com/WiringPi/WiringPi.git  

This will make a folder in your current directory called WiringPi. Head to the Wiring Pi directory. 

cd WiringPi 

Then pull the latest changes from the origin. 

git pull origin 

Then enter the following command. The ./build is a script to build Wiring Pi from the source files. This builds the helper files, modifies some paths in Linux and gets WiringPi ready to rock. 


At this point, the library should work. Run the gpio command shown below to view some information about the wiringPi version and the Pi that it is running on. 

gpio -v 

Entering the following command will draw a table illustrating the configuration for the pins in the 40-pin connector. 

gpio readall 

Download the Lora-transceiver code

In the terminal, run 

wget https://codeload.github.com/dragino/rpi-lora-tranceiver/zip/master 

Unzip the library 

unzip master 

STEP 4(Pin numbers and frequency update):

Update the pin numbers and frequency by opening the main.c file. Change directory to go inside the folder with the main.c file using the command given below: 

cd rpi-lora-transceiver-master/ dragino_lora_app 

Then, using the nano editor, open the main.c file using the command below: 

Nano main.c 

Scroll down in the main.c file the line shows frequency and raspberry connection according to the below image: 

Change the pin numbers and frequency in the nano editor. Press Ctrl+X to exit nano. Upon exiting, the save prompt will be displayed. Press Y and then press the Enter key. 

STEP 5(Rebuild the main.c file):

Every time the code is edited, it needs to be rebuilt in order for the changes to take effect. Use the commands below to clean any previous build files present and to rebuild the source 

make clean  


STEP 6(Explanation of the code)

Lora initialization: The SetupLoRa function prepares the LoRa module for operation by setting the necessary parameters and configurations specific to the chosen chip version (SX1272 or SX1276). 

Sender part: In the sender, the function opmodeLora() sets the LoRa module's operating mode to LoRa mode using the opmode function. The configPower function is called to configure the transmit power of the LoRa module. The code then prints information about the LoRa transmission settings, including the spreading factor (sf) and frequency (freq). The hello buffer represents the payload of the LoRa message which is to be sent. You can change that payload according to you. Finally, the program enters a loop where it repeatedly calls the txlora function to send the message stored in the hello buffer.

if (!strcmp("sender", argv[1])) { 


        // enter standby mode (required for FIFO loading)) 



writeReg(RegPaRamp, (readReg(RegPaRamp) & 0xF0) | 0x08); // set PA ramp-up time 50 uSec 




        printf("Send packets at SF%i on %.6lf Mhz.\n", sf,(double)freq/1000000); 



        if (argc > 2) 

            strncpy((char *)hello, argv[2], sizeof(hello)); 


        while(1) { 

            txlora(hello, strlen((char *)hello)); 



Receiver part: In the receiver part, the receivepacket function is called repeatedly in the receiver part of the code to check for incoming packets and print their details. It provides insights into the received signal's strength, quality, and payload content. In the main function, the receiver part initializes the LoRa module for reception and continuously listens for incoming packets, printing information about each received packet.


else { 


        // radio init 




        printf("Listening at SF%i on %.6lf Mhz.\n", sf,(double)freq/1000000); 


        while(1) { 






STEP 7(Running the receiver):

Run the receiver code using the command below 

./dragino_lora_app rec 


NOTE: For using the Raspberry Pi as transmeter complete the setup as shown above but for executing the transmeter code use the below command.  

./dragino_lora_app sender 


The use of Raspberry Pi Node to Node communication using IoTIF LoRa technology opens up a world of possibilities for the Internet of Things (IoT) enthusiasts. The circuit diagram presented in this blog serves as a valuable guide for implementing this powerful communication solution. By harnessing the low-power, long-range capabilities of LoRa, we can create robust and scalable IoT networks that connect devices seamlessly. With this technology, the potential for innovative applications is endless. So, whether you're a hobbyist or a professional, don't miss out on the chance to explore the exciting realm of Raspberry Pi Node to Node communication with IoTIF LoRa. Discover new possibilities and unleash your creativity today!


If you appreciate our work don't forget to share this post and leave your opinion in the comment box.


Please do check out other blog posts about Popular electronics


Make sure you check out our wide range of products and collections (we offer some exciting deals!)

Components and Supplies

You may also like to read

Frequently Asked Questions

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.

Components and Supplies

You may also like to read