RAK7248 LoRaWAN Network Server Guide
This guide explains how to connect the RAK7248/RAK7248C/RAK7248P WisGate Developer D4H Gateway to The Things Stack, ChirpStack, or AWS IoT Core for LoRaWAN.
Before connecting to a LoRaWAN Network Server, follow the Gateway Configuration guide to connect the gateway to the Internet, configure the channel plan, and select the LoRaWAN server.
The Things Stack
The Things Network (TTN) enables low-power devices to use long-range gateways to connect to an open-source, decentralized network to exchange data through an Application. Learn more about the Things Network through their documentation.
In this section, you will learn how to connect RAK7248/RAK7248C/RAK7248P WisGate Developer D4H Gateway to TTNv3.
-
You should have connected your gateway to the internet through the router according to the method introduced in the Accessing the Internet section.
-
Configure your gateway and choose TTN as the LoRa Server. Choose a correct frequency according to the method introduced in the Configuring the Gateway section.
-
For the TTN Console registration steps, refer to:How to Register a RAK Gateway in TTN v3
ChirpStack
ChirpStack is an open-source LoRaWAN Network Server. Learn more through the ChirpStack documentation.
For RAK7248/RAK7248C/RAK7248P, you can use the built-in ChirpStack or connect the gateway to an independent ChirpStack server.
Using the Built-in ChirpStack
There is a built-in ChirpStack in every RAK Developer gateway if you use the latest firmware or the rak_common_for_gateway repository.
When you use it for the first time after burning the latest firmware, the gateway will work in the EU868 Band, and it will use the built-in ChirpStack as its default LoRa Server. If you don't want to change the frequency or LoRa Server, you don't have to do anything as this will be configured automatically when the gateway boots.
However, if it is not the first time you use the gateway and you want to use the built-in ChirpStack as the LoRa Server, follow the Gateway Configuration guide to select ChirpStack and configure the channel plan.
- Optional - If you disabled AP Mode and connected the gateway to your Wi-Fi network in Client Mode, you can search for the gateway IP address using Advanced IP Scanner.
There is a web-based UI that comes with the ChirpStack instance. Open a browser and enter the following information:
- Browser Address:
<Gateway IP address>:8080(Example: http://192.168.0.100:8080) - Username: admin
- Password: admin
It is recommended to change the default password to improve account security. You can change the password from the user menu in the ChirpStack web interface.
Figure 1: ChirpStack web-based UIEverything should be pre-configured. Device profiles have been created, and the gateway has been registered with the server. Go to the Gateways tab and click rak_gateway to open the gateway details page.
Figure 1: Available gateways in ChirpStackGo to Gateways and check the Last seen status. A recent timestamp indicates that the gateway is visible to the ChirpStack server.
Figure 1: Last seen statusUsing an Independent ChirpStack
Using an Independent ChirpStack
You can setup an independent ChirpStack by yourself and can set a ChirpStack in AWS. Refer to the AWS guide. If you want to run ChirpStack on a different host/cloud, then refer to the guide on the ChirpStack site.
Remember to run the sudo gateway-config command in the CLI and point the gateway to the IP address of the machine you just installed ChirpStack on. This can be done in item 2 in the menu Setup RAK Gateway LoRa concentrator.
Assuming you have set it up correctly, log in to your ChirpStack to register your gateway.For the ChirpStack registration steps, refer to: How to Register a RAK Gateway in ChirpStack v3
AWS IoT Core for LoRaWAN
Set Up Your AWS Account and Permissions
Execute the following steps to set up your AWS account and permissions.
If you don't have an AWS account, refer to Set up your AWS account. The relevant sections are Sign up for an AWS account and Create a user and grant permissions.
The high-level steps to get started with AWS IoT Core for LoRaWAN are as follows:
- Set up Roles and Policies in IAM
- Add a Gateway (see section Add the Gateway to AWS IoT)
- Add Device(s) (see section Add a LoRaWAN Device to AWS IoT)
- Verify device and service profiles
- Set up a Destination to which device traffic will be routed and processed by a rule.
These steps are discussed in this guide. For additional details, refer to the AWS IoT Core for LoRaWAN Developer Guide.
Add the Gateway to AWS IoT
Preparation
Refer to the online guide for steps required prior to onboarding your gateway. For more details, check the software section of the datasheet.
Frequency Band Selection and Role Setup
Refer to the online guide for information on selecting an appropriate frequency band.
LoRa Frequency bands supported by RAK7248 are as follows:
- RU864
- IN865
- EU868
- US915
- AU915
- KR920
- AS923
- CN470
You can select an appropriate frequency band from the RAK store.
Add the LoRaWAN Gateway
To register the gateway with AWS IoT Core for LoRaWAN, follow the steps in the online guide under the Add a gateway using the console section.
Set Up the Gateway
Before continuing, complete the following guides:
For additional software references, check the following link:
Configure the Gateway Device
- To connect to the AWS IoT Core for LoRaWAN, you need to download and compile BasicsStation. Assuming that you have successfully accessed the gateway via SSH, it is a good policy to update/upgrade. Doing so, it will update all the packages:
sudo apt update
sudo apt upgrade
- Now, register the gateway in AWS IoT Core for LoRaWAN. To register your gateway, you will need the device’s EUI. To find the gateway’s EUI, run the command below to open the Graphics User Interface (GUI). The EUI can be found on the top of the GUI:
sudo gateway-config
Figure 1: RAK7248 Configuration OptionsYou can also run the following command:
Figure 1: Gateway Versionpi@rak-gateway:~ $ sudo gateway-version
Raspberry Pi 4 Model B Rev 1.1, OS "10 (buster)", 5.4.79-v7l+.
RAKwireless gateway RAK7248 no LTE version 4.2.7R install from firmware
Gateway ID: DCA632FFFE366417
- Only the configuration of the Basics station remains. Clone the Basics station repository and enter the downloaded folder:
git clone https://github.com/lorabasics/basicstation.git
cd basicstation
Run the following commands in the basicstation directory.
- Install all the dependencies by running the following command:
make platform=corecell variant=std
- Replace the file
loragw_stts751.cfile using the following command:
sudo cp -f /opt/ttn-gateway/sx1302_hal/libloragw/src/loragw_stts751.c deps/lgw1302/platform-corecell/libloragw/src/loragw_stts751.c
- Make a clean build in the basicstation directory, and then do a
maketo install all dependencies with the changes.
make clean
make platform=corecell variant=std
- As the installation is complete, you need to configure the Basics Station protocol. Enter the folder with the given examples by Semtech and specifically corecell folder as the build is for SX1302.
cd examples/corecell
- First, change the reset pin in the
reset_gw.shto 17 in order to successfully start the concentrator.
#!/bin/sh
# This script is intended to be used on SX1302 CoreCell platform, it performs the following actions:
# - export/unexport GPI023 and GPI018 used to reset the SX1302 chip and to enable the LDOs
#
# Usage examples:
# ./reset_lgw.sh stop
# ./reset_lgw.sh start
#
# GPIO mapping has to be adopted with HW
#
SX1302_RESET_PIN=17
SX1302_POWER_EN_PIN=18
WAIT_GPIO() {
sleep 0.1
}
- Create a new folder to store all the configuration files for basics station to connect to AWS IoT Core for LoRaWAN.
mkdir lns-aws
- Copy
station.confinto this folder.
cp lns-ttn/station.conf lns-aws/
- Add the certificates that you downloaded earlier to lns-aws. (Refer to Add the LoRaWAN Gateway.)
Figure 1: Gateway Certificate
Figure 1: Provisioning Credentials- All the configurations for basics stations are ready. You should now have the files as follows:
pi@rak-gateway:~/basicstation/examples/corecell/lns-aws $ ls -al
total 28
drwxr-xr-x 2 pi pi 4096 Oct 28 17:57 .
drwxr-xr-x 4 pi pi 4096 Oct 28 17:44 ..
-rw-r--r-- 1 pi pi 1225 Oct 28 17:57 cups.crt
-rw-r--r-- 1 pi pi 1680 Oct 28 17:57 cups.key
-rw-r--r-- 1 pi pi 1607 Oct 28 17:57 cups.trust
-rw-r--r-- 1 pi pi 69 Oct 28 17:57 cups.uri
-rw-r--r-- 1 pi pi 2460 Oct 28 17:46 station.conf
- Before you start using basics station, disable the packet forwarder.
Use the command
sudo systemctl edit ttn-gateway.serviceto edit the service of packet forwarder, and add the following codes to the file.
If you want to re-activate the packet forwarder, you can just set the value of Restart to always.
[Unit]
Description=The Things Network Gateway
[Service]
WorkingDirectory=/opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/
ExecStart=/opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/start.sh
SyslogIdentifier=ttn-gateway
Restart=no
RestartSec=5
[Install]
WantedBy=multi-user.target
- To apply the changes made to the unit, execute the following command:
sudo systemctl daemon-reload
- Restart the ttn-gateway service to load the new service configuration. The unit file must be restarted if you modify the running unit file.
sudo systemctl restart ttn-gateway.service
- Find the ttn-gateway process PID and
killthis process:
pi@rak-gateway:~/basicstation/example/corecell/lns-aws $ ps aux | grep ttn-gateway
pi 28165 0.2 0.1 7680 2780 pts/0 S+ 18:20 0:00 /bin/bash/opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/start.sh
pi 28236 0.0 0.0 7348 488 pts/1 S+ 18:20 0:00 grep --color=auto ttn-gateway
pi@rak-gateway:~/basicstation/example/corecell/lns-aws $ sudo kill 28165
- Now, you can start basics station. Exit the configuration folder and start basics station.
cd ..
./start-station.sh -l ./lns-aws
Figure 1: Configuring the Basics StationIf everything is configured properly, your gateway should be online in the AWS IoT Core for LoRaWAN console:
Figure 1: Connected Status in the LoRaWAN ConsoleAdd a LoRaWAN Device to AWS IoT
Preparation
Refer to RAK4631 Quick Start Guide to enable communication with the gateway.
- Go to the datasheet to learn more about the RAK4631 WisBlock LPWAN Module.
- Follow the steps in the online guide under the Before onboarding your wireless device section, then proceed to the Add your wireless device to AWS IoT Core for LoRaWAN section.
Verify Profiles
AWS IoT Core for LoRaWAN supports device profiles and service profiles. Device profiles contain the communication and protocol parameter values the device needs to communicate with the network server. Service profiles describe the communication parameters the device needs to communicate with the application server.
Some pre-defined profiles are available for device and service profiles. Before proceeding, verify that these profile settings match the devices you will be setting up to work with AWS IoT Core for LoRaWAN. For more details, refer to the online guide under the Add profiles to AWS IoT Core for LoRaWAN section.
Proceed only if you have a device and service profile that will work for you.
Set Up a Destination for Device Traffic
Because most LoRaWAN devices don't send data to AWS IoT Core for LoRaWAN in a format that can be consumed by AWS services, traffic must first be sent to a Destination. A Destination represents the AWS IoT rule that processes a device's data for use by AWS services. This AWS IoT rule contains the SQL statement that selects the device's data and the topic rule actions that send the result of the SQL statement to the services that will use it.
For more information, refer to the online guide under the Add a destination using the console and Create an IAM role for your destinations sections. Also, refer to the Create rules to process LoRaWAN device messages section in the same guide.
Add End-Devices
Refer to RAK4631 Quick Start Guide to enable communication with the gateway.
Connect the Device and Verify the Connection Status
Follow the instructions in the online guide to connect your device to AWS IoT Core for LoRaWAN. To verify the connection status, refer to the instructions in the Check device connection status using the console section. You can also check View format of uplink messages sent from LoRaWAN devices.
For instructions on processing uplink data, creating rules, sending downlinks, and integrating other AWS services, refer to the AWS IoT Core for LoRaWAN Application guide.
