How to build a LoRa gateway using Raspberry Pi?
[Copy link]
As the name suggests, Long Range Wide Area Network or LoRaWAN technology is widely used for long-range, low-power communications in the Internet of Things (IoT).
In this article, we will guide you on how to connect a SX130x 868M LoRaWAN Gateway Module to a Raspberry Pi 4 via a Hardware Attached On Top (HAT). This setup creates a LoRaWAN Gateway, allowing the Raspberry Pi (RPi) to communicate with LoRaWAN enabled devices.
Materials Needed:
Step 1. Gather the hardware
Before you get started, you need to prepare all the required hardware components, including a Raspberry Pi4, a SX130x 868M LoRaWAN gateway module, a LoRa antenna, and a working MicroSD card with Raspbian OS.
Step 2. Assemble the hardware
Insert the MicroSD card into the Raspberry Pi (after the RPi has been installed - see instructions in step 3)
Connect the SX130x LoRaWAN Gateway module to the GPIO pins of the Raspberry Pi. Make sure the pins are aligned correctly and the module is securely connected. It is a HAT so it should fit perfectly.
Figure 1. Assembled hardware between the SX130x LoRaWAN gateway module and the Raspberry Pi’s GPIO pins
Step 3. Install the operating system for the Raspberry Pi
Use this link to download and install the Raspberry Pi Imaging Software.
https://www.raspberrypi.com/software/
Figure 2: Raspberry Pi software
Click Select Operating System.
Figure 3: Select OS in Imager software
Select the 32-bit OS Lite version and then select the storage device option in the next step.
Figure 4: Select the storage device option
Next, insert your SD card into your computer using an SD card reader. Select the SD card that appears. Be sure to click the gear icon before clicking the “Write” button.
Figure 5. Use the gear button to change Wi-Fi settings and other options.
Then, click Write Image.
Now, change the WiFi settings and other options. Then, click "Enable SSH" and set your username and password. Click "Configure Wireless LAN" and enter the SSID and password for your WiFi. This allows the RPi to boot without being connected to the desktop screen.
Figure 6, add your Wi-Fi SSID and password.
Click on “Save” and then click on the “Write” button. Wait for the process to complete and once it is finished, remove the SD card from its current device and insert it into your Raspberry Pi.
Step 4. Connect to the Raspberry Pi using SSH
After assembly and inserting the SD card, power on the Raspberry Pi. Follow the instructions below to establish an SSH connection.
Figure 7. After connecting to the RPi using SSH, the power is turned on.
Make sure the IP address of the Raspberry Pi is correct for establishing a connection. To do this, download the Angry IP Scanner software : https://angryip.org/
Figure 8, Angry IP software.
After clicking "Start", the following screen will appear. Once the process is complete, find the IP address for the hostname "Raspberry pi". You can also find the correct information in the DHCP section of your router's configuration page.
Figure 9, IP scanning process.
In our example, the IP address is 192.168.1.4. However, your situation may be different. Next, download the bitvise ssh software: https://bitvise.com/ssh-client-download
Launch the software and log into the IP address using the username and password you set during the SD card flash process.
Figure 10. The process of transferring SSH to the RPi.
Click "New Terminal Console"
Figure 11, click “New Terminal Console”.
After that, you will see the following screen.
Figure 12. The Terminal screen after logging in.
We have successfully established an SSH connection to the Raspberry Pi.
Step 5. Configure the RPi
Enable SPI, Serial and I2C using this command: "raspi-config"
Figure 13. The System Options window for configuring the RPi.
Go to System Options and enable SPI, Serial, and I2C.
Figure 14. Configuring the RPi by enabling SPI, I2C, and Serial on the Interfaces window.
Click "Yes".
Figure 15. Click “Yes” for all three options.
It will then ask to reboot.
Step 6. Connect SX1302
Install the SX1302 gateway binary file by following the steps below
Next, it is necessary to verify that the hardware is properly connected.
Once a connection is made to the hardware, you will observe output similar to this…
Figure 16, “Get Chip ID” command.
Your EUI ID is the MAC address of your gateway, so be sure to write it down. Start the LoRa Concentrator shield with this command and provide any configuration files in the folder.
A successful connection to the LoRa concentrator will look similar to this:
Figure 17: The gateway has started and successfully established a connection with the LoRa concentrator
At this point, any data sent via the EU868 profile will be received on this screen.
Conclusion
Sending data through this gateway will enable data reception. The next step involves connecting, configuring, and managing the gateway using Chirpstack.
|