This guide will show you how to set up the Raspberry Pi and make it work with the RAK LPWAN HATs. The setup of the Raspberry Pi consists of three parts:
- Flashing the Raspbian OS to the SD card and access option
- Configuring the Raspberry Pi interfaces
- Installing the rak_common_for_gateway stack
You have two options in configuring the Raspberry Pi:
- Headless setup - you don't need a monitor and a keyboard
- General Setup - you need a monitor and a keyboard
Flash the SD Card
Flashing the latest Raspberry Pi OS is required for both the headless and the general setup. To flash the OS, you will need:
- balenaEtcher (software used for flashing OS)
- Raspberry Pi OS
- SD card (at least 16 GB)
- SD card reader
- PC/laptop
Start with downloading and installing balenaEtcher.
Next, download the latest Raspberry Pi OS. The Raspberry Pi OS Lite is recommended as it is more lightweight than the Desktop version.
Insert the SD card into your PC/laptop and open balenaEtcher. Click on Flash from file, browse and select the Raspberry Pi OS you have downloaded.
BalenaEtcher should automatically recognize the SD card. If not, click on Select target and choose your SD card.
Once the Raspberry Pi OS and SD card are selected, click on Flash. Flashing will then start.
Once the flashing is done, you will see the following screen.
You can now safely eject the SD card.
Raspberry Pi Headless Setup
This setup does not require a monitor or any input devices. The Raspberry Pi can be configured screenless; that is why it is called a Headless setup. By default, the Raspberry Pi OS installs the SSH protocol disabled. You can turn it on without using a monitor and keyboard.
Requirements
Hardware
- Raspberry Pi 3B+/4
- Power adapter 5 V (at least 2.5 A for Raspberry Pi 3B+ and 3 A for Raspberry Pi 4)
- SD card (at least 16 GB, with the flashed OS)
- SD card reader
- A PC/ Laptop
Software
- SSH terminal console (e.g. PuTTY)
Setup the SD card
Assuming you have flashed the latest Raspberry Pi OS, insert the SD card into your PC/laptop. Open the root of the directory of the card.
In here, create a text file called wpa_supplicant.conf
. The wpa_supplicant includes the needed information for the Wi-Fi interface of the Raspberry Pi to connect to a Wireless network.
Copy and then paste the following text into the wpa_supplicant.conf
file:
country=YOUR_COUNTRY
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
scan_ssid=1
ssid="YOUR_WIFI_SSID"
psk="YOUR_WIFI_PASSWORD"
}
Change YOUR_COUNTRY with the abbreviation of your country. Here you can find your country's two-letter code, according to ISO standards.
Also, change YOUR_WIFI_SSID with the SSID of your network and YOUR_WIFI_PASSWORD with the password of that network.
đź“ť NOTE: Type the SSID and Password in the quotes (" "). |
Save and exit the text file.
If you want to use the Ethernet interface, plug the Raspberry Pi directly into your wired network. The DHCP server of the router will assign an IP to the Raspberry Pi.
Apart from the wpa_supplicant.conf
file, also create an empty file (with no extension) named ssh
. This will enable the SSH interface on the Raspberry Pi.
Now you can eject the SD card and insert it into the Raspberry Pi. Once Pi is booted, it will connect to the WI-FI network. The DHCP server will assign an IP and you can access the Pi at that address.
To find the assigned IP, you can either go to your router’s web UI in the DHCP clients menu or use a program (in this example Advanced IP Scanner) to scan the network.
You can access the Raspberry Pi on that IP using a terminal console (in this example: PuTTY)
Login using the default credentials:
- Login: pi
- Password: raspberry
You can now head to Configuring the Raspberry Pi's Interfaces
General Setup
In the general Raspberry Pi setup, you will learn how to setup the Pi with the help of a monitor and a keyboard.
Requirements
Hardware
- Raspberry Pi 3B+/4
- Power Adapter (at least 2.5A for Raspberry Pi 3B+ and 3A for Raspberry Pi 4)
- SD card (at least 16GB, with the Raspberry Pi OS flashed)
- SD card reader
- Keyboard
- Monitor/ TV
Setup the Raspberry Pi
Assuming you have flashed the latest Raspberry Pi OS, insert the SD card into your Raspberry Pi.
Connect the monitor/ TV to the HDMI port (for Raspberry Pi 3B+) or MiniHDMI (for Raspberry Pi 4), and the keyboard to a USB port. Optionally, you can connect an Ethernet cable, if you want to use Ethernet. In this example, it will be shown how to connect the Raspberry Pi to a WI-FI network.
Once everything is connected, you can power the Raspberry Pi with the power adapter. When the Pi is fully booted, you will see the following screen.
Login using the default Raspberry credentials:
- Login: pi
- Password: raspberry
Configuring the Raspberry Pi's Interfaces
After you log in, you need to configure the Raspberry Pi – enable SSH, SPI, I2C, etc. To do this, run the command sudo raspi-config
. This opens the Raspberry Pi user interface (UI), where you can configure different Raspberry Pi settings.
If you want to be able to access the Raspberry via SSH connection, head to 3 Interface Options and enable I2 SSH.
đź“ť NOTE: If you are using the Headless setup , you can skip this step as the SSH interface is enabled via the ssh file. |
đź“ť NOTE: Enabling the SSH makes the Raspberry Pi accessible via the command terminal. It is recommended to change the login password in 1 System Options -> S3 Password. |
While you are in the 3 Interface Options menu, enable the following interfaces:
- SPI – Serial Peripheral Interface. This enables the communication between the Raspberry Pi and the concentrator with an SPI interface.
đź“ť NOTE: If you are going to use an LPWAN concentrator with a USB interface and a mPCIe to USB Board, you can skip enabling this interface. |
-
I2C – enables the Inter-Integrated Circuit (I2C) interface. The I2C enables GPS communication.
- Disable Login Shell over Serial and enable Serial port hardware – here you disable Shell over Serial and enable the Serial port as it might cause a collision between the interfaces.
It is recommended to configure the Time Zone of the Raspberry Pi. Head to 5 Localization Options -> L2 Time Zone
Select your geographic area and then a city corresponding to your time zone.
Now, you can configure the WI-FI Internet connection. Head to 1 System Options -> Wireless LAN.
đź“ť NOTE: If you are using the Headless setup, you can skip this step, as the Internet connection is configured in the wpa_supplicant.conf file. |
Enter the SSID of your Wireless Network and then the password of that network.
Once done with configuring the Raspberry Pi, select Finish. The Pi will require a reboot to apply the changes.
After the reboot, the session in the terminal will be closed. You need to log in again and install the latest rak_common_for_gateway
stack.
Install rak_common_for_gateway stack
Log into the Raspberry Pi.
It is a good practice to update the Raspberry Pi packages. To do this run the following command:
sudo apt update && sudo apt upgrade -y
Proceed by installing the rak_common_for_gateway stack. Run the following commands to install it.
Install Git on the Raspberry Pi
sudo apt update; sudo apt install git –y
Clone the rak_common_for_gateway stack
git clone https://github.com/RAKWireless/rak_common_for_gateway.git ~/rak_common_for_gateway
Enter the cloned folder and install the stack.
cd ~/rak_common_for_gateway
sudo ./install.sh
Choose the desired model of the gateway by typing the number and clicking Enter.
For example, if you are using RAK2287 SPI without LTE, you will need to type 7 and hit enter to start the installation.
Alternatively, if you are going to use RAK5146 USB without LTE, you will need to type 10 and start the installation.
When the installation is complete, you will see the following on your screen.
Now you can proceed with connecting the gateway to a LoRaWAN Network Server (LNS).
You can refer to each RAK concentrator documentation below:
Updated