Install Semtech Basic Station on RAK831
Information
Basic station information:
Guide: https://doc.sm.tc/station/index.html
Github: https://github.com/lorabasics/basicstation
Procedure
Step A. Prepare the Raspberry Pi 3.
- This guide is part of LoRa/LoRaWAN tutorial 52, see presentation lora_part52.pdf
This guide uses a RAK831 gateway, see presentation LoRa/LoRaWAN tutorial 28.1
The RAK831 gateway uses a Raspberry Pi 3 as the Micro Controller Unit (MCU).
- This guide assumes that you have already done the following.
For instructions, see LoRa/LoRaWAN tutorial 28.1:
- Raspbian Lite is installed. In this guide I have installed Raspbian Buster Lite.
- The system date, timezone and locale are correctly set.
- SPI is enabled.
- In this guide the gateway will operate in the Netherlands in the 863-870 MHz frequency band (EU863-870),
and the gateway has ip address: 192.168.1.11.
- To access the RAK831 gateway from a computer:
Open a terminal
Type: ssh [email protected]
Step B. Install Semtech Basic Station.
-
ATTENTION:
THE BASICSTATION IN THIS GUIDE WILL NOT USE A CUPS SERVER.
IT USES A LNS SERVER WHICH IS THE CHIRPSTACK NETWORK SERVER, WHICH CAN BE ACCESSED BY:
ws://localhost:3001
THE BASICSTATION SENDS PACKAGES TO THE CHIRPSTACK NETWORK SERVER USING THE WEBSOCKET (WS) PROTOCOL.
- Make sure you have done step A before you continue.
- Upgrade the Raspberry Pi packages.
Type: cd ~
Type: sudo apt-get update && sudo apt-get upgrade -y
- Clone my basicstation_setup git repository.
Type: git clone https://github.com/robertlie/basicstation_setup.git
- Execute install.sh as root. You must be root!
Type: cd basicstation_setup
Type: sudo ./install.sh
This install.sh script, does the following. All commands should be executed as root:
- Create /opt/semtech directory.
Type: mkdir /opt/semtech
- Clone the Semtech basic station git repository:
Type: cd /opt/semtech
Type: git clone https://github.com/lorabasics/basicstation.git
- The SPI_SPEED in basicstation/deps/lgw/platform-rpi/libloragw/src/loragw_spi.native.c must be lowered
from 8000000 to 2000000 because there is a high probability that high spi rate will cause sx1301 to fail to start.
This solution originated from the RakWireless Forum
File loragw_spi.native.c is an dependency, which does not exists yet, it will be downloaded when building basicstation.
EXECUTE IN THIS SPECIFIC ORDER:
Step a.
Download and build the dependencies (deps) for the Semtech basic station:
Type: cd /opt/semtech/basicstation
Type: make platform=rpi variant=std deps
Step b.
Clean the builds. DO NOT USE TARGET: super-clean, this will remove the downloaded dependencies:
Type: make platform=rpi variant=std clean
Step c.
Modify file: basicstation/deps/lgw/platform-rpi/libloragw/src/loragw_spi.native.c
The SPI_SPEED value needs to be changed:
From:
#define SPI_SPEED 8000000
To:
#define SPI_SPEED 2000000
Type:
sed -i 's/SPI_SPEED[[:space:]]\+8000000/SPI_SPEED 2000000/g' deps/lgw/platform-rpi/libloragw/src/loragw_spi.native.c
- Now build the Semtech basic station. The dependencies will not be downloaded again (unless you used super-clean):
Type: make platform=rpi variant=std
- Copy ~/basicstation_setup/startup folder to /opt/semtech/basicstation.
Type: cp -R ~/basicstation_setup/startup /opt/semtech/basicstation/startup
- Copy /opt/semtech/basicstation/examples/live-s2.sm.tc/station.conf to /opt/semtech/basicstation/startup/config_files.
Type: cp /opt/semtech/basicstation/examples/live-s2.sm.tc/station.conf /opt/semtech/basicstation/startup/config_files
- Copy /opt/semtech/basicstation/examples/live-s2.sm.tc/version.txt to /opt/semtech/basicstation/startup/config_files.
Type: cp /opt/semtech/basicstation/examples/live-s2.sm.tc/version.txt /opt/semtech/basicstation/startup/config_files
Note:
The config_files directory will finally contain the following 3 files:
- version.txt
- station.conf
- tc.uri
The tc.uri file contains only one line: ws://localhost:3001
This means a local LNS is setup and there is no need for a secure websocket.
Do not use wss use ws! This also means no need for tc*.key, tc*.crt and tc*.trust files.
As explained earlier the LNS will be a ChirpStack Network Server.
The ChirpStack Network Server and other ChirpStack components will be installed later.
- Start basic station, execute start.sh as root.
Type: cd /opt/semtech/basicstation/startup
Type: sudo ./start.sh
This start.sh script, does the following. All commands should be executed as root:
- Set basic station environment variables, type:
export RADIODEV="/dev/spidev0.0"
export STATION_RADIOINIT="/opt/semtech/basicstation/startup/reset.sh"
export STATION_LOGLEVEL="1"
The log levels are:
0=XDEBUG, 1=DEBUG, 2=VERBOSE, 3=INFO, 4=NOTICE, 5=WARNING, 6=ERROR, 7=CRITICAL
The above mentioned reset.sh script contains the following:
#! /bin/bash
# Reset SX1301_RESET_BCM_PIN
SX1301_RESET_BCM_PIN=17
echo "$SX1301_RESET_BCM_PIN" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/direction
echo "0" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/value
sleep 0.1
echo "1" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/value
sleep 0.1
echo "0" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/value
sleep 0.1
echo "$SX1301_RESET_BCM_PIN" > /sys/class/gpio/unexport
- Start basic station:
Type: cd /opt/semtech/basicstation/startup/config_files
Type: cd /opt/semtech/basicstation/build-rpi-std/bin/station -p -f
In the logging you can see that the station is running in NO CUPS mode and TC connect fails.
LNS server (TC) is no setup yet. Will be done next.
Write down the Station EUI, for example: b827:ebff:fec7:4b36
|