How To Get Started with Raspberry Pi and RAK LPWAN Concentrators

KHM-032-00.jpg

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:

  1. Flashing the Raspbian OS to the SD card and access option
  2. Configuring the Raspberry Pi interfaces
  3. Installing the rak_common_for_gateway stack

You have two options in configuring the Raspberry Pi:

  1. Headless setup - you don't need a monitor and a keyboard
  2. 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:

  1. balenaEtcher (software used for flashing OS)
  2. Raspberry Pi OS
  3. SD card (at least 16 GB)
  4. SD card reader
  5. PC/laptop

Start with downloading and installing balenaEtcher.

KHM-032-01.png

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.

KHM-032-02.png

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.

KHM-032-03.png

Once the flashing is done, you will see the following screen.

KHM-032-04.png

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

  1. Raspberry Pi 3B+/4
  2. Power adapter 5 V (at least 2.5 A for Raspberry Pi 3B+ and 3 A for Raspberry Pi 4)
  3. SD card (at least 16 GB, with the flashed OS)
  4. SD card reader
  5. A PC/ Laptop

Software

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

KHM-032-05.png

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 (" ").

KHM-032-06.png

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.

KHM-032-07.png

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.

KHM-032-08.png

You can access the Raspberry Pi on that IP using a terminal console (in this example: PuTTY)

KHM-032-09.png

Login using the default credentials:

  • Login: pi
  • Password: raspberry

KHM-032-010.png

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

  1. Raspberry Pi 3B+/4
  2. Power Adapter (at least 2.5A for Raspberry Pi 3B+ and 3A for Raspberry Pi 4)
  3. SD card (at least 16GB, with the Raspberry Pi OS flashed)
  4. SD card reader
  5. Keyboard
  6. Monitor/ TV

Setup the Raspberry Pi

Assuming you have flashed the latest Raspberry Pi OS, insert the SD card into your Raspberry Pi.

KHM-032-011.png

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.

KHM-032-012.png

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.

KHM-032-013.png

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.

KHM-032-014.png

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.

KHM-032-015.png

KHM-032-016.png

đź“ť 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.

KHM-032-017.png

  • I2C – enables the Inter-Integrated Circuit (I2C) interface. The I2C enables GPS communication.
    KHM-032-018.png
  • 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.
    KHM-032-019.png

It is recommended to configure the Time Zone of the Raspberry Pi. Head to 5 Localization Options -> L2 Time Zone

KHM-032-020.png

Select your geographic area and then a city corresponding to your time zone.

KHM-032-021.png

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.

KHM-032-022.png

Enter the SSID of your Wireless Network and then the password of that network.

KHM-032-023.png

Once done with configuring the Raspberry Pi, select Finish. The Pi will require a reboot to apply the changes.

KHM-032-024.png

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.

KHM-032-025.png

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.

KHM-032-026.png

When the installation is complete, you will see the following on your screen.

KHM-032-027.png

Now you can proceed with connecting the gateway to a LoRaWAN Network Server (LNS).

You can refer to each RAK concentrator documentation below:

  1. RAK2245
  2. RAK2247
  3. RAK2287
  4. RAK5146

Updated