Skip to content

Country

Getting Started with the RAK831 LoRa Gateway and Raspberry Pi

Getting Started with the RAK831 LoRa Gateway and Raspberry Pi

This quick guide will show you how to connect your RAK831 concentrator module to the Raspberry Pi and configure the software to connect to TTN via Ethernet or Wi-Fi connection.

What you need

You will need the following hardware components to get started with this guide:

Objective

This guide is for those of you that have purchased one of the above kits from the Pi-Supply Store and need a quick guide in getting everything setup, linking the hardware together and installing and configuration the software. This guide will assume that you have some basic knowledge of the Raspberry Pi hardware and Rapbian operating system as well as knowing the GPIO pinouts of the 40-pin header.

Setup the Hardware

Step 1 – Insert the micro SD card with Raspbian OS on to your Raspberry Pi. Connect your HDMI cable and USB mouse and Keyboard, if you have ethernet then you can also connect this now. Once you have connected all your peripherals to the Raspberry Pi, go ahead and connect the power supply, which should boot up the Pi.

Step 2 – Before we connect the RAK831 concentrator board to the Raspberry Pi you should connect the antenna that came supplied in your kit. Make sure that the antenna is screwed in to the connector all the way but don’t over tighten it.

Step 3 – Now lets connect the RAK831 to the Raspberry Pi using the male to female jumper cables in the kit. Connect the cables according to the table below.

RAK831 Pins Description Raspberry Pi Pin
1 5V 2
3 GND 6
19 RST (Reset Pin) 17
18 SCK (SPI Clock) 23
17 MISO 21
16 MOSI 19
15 CSN (Chip select) 24

Table 1-1: RAK831 and Raspberry Pi jumper wires connections

Step 4 – We need to enable the SPI serial on the Raspberry Pi so we can communicate with the RAK831 module. To enable SPI do the following:

  • Run sudo raspi-config from the terminal window
  • Use the down arrow to select 9 Advanced Options
  • Arrow down to A6 SPI
  • Select Yes wen it asks you to enable SPI
  • Also select Yes when it asks about automatically loading the kernel module
  • Use the right arrow to navigate to <Finish> button
  • Select Yes to reboot

The system will then reboot and when it comes back on, enter the following command in the terminal window:

ls /dev/*spi*

The Raspberry Pi should respond with the following:

/dev/spidev0.0 /dev/spidev0.1

These represent the SPI devices on chip enable pins 0 and 1, which are hardwires into the Raspberry Pi.

Software Installation

Step 1 – Make sure that your Raspberry Pi is up to date with the latest software by running the following command, whilst making sure you have git installed:

sudo apt-get update

sudo apt-get install git

Step 2 – Clone the RAK831 gateway software to your Raspberry Pi and start the installer with the following command:

git clone https://github.com/ttn-zh/ic880a-gateway.git

cd ~/ic880a-gateway

sudo ./install.sh

The installer will present you with a EUI number, which at this point you should make a note of as you will need it to register your gateway with TTN.

When prompted to use the remote setting file enter N at this point.

Step 3 – Fill out the rest of your gateway information:

If you do not know your GPS coordinates then you can simply enter 0. You can configure the exact location in the TTN gateway configuration page.

The information entered here gets stored in a configuration file which is in /opt/ttn-gateway/bin/local_conf.json. Once finished reboot your Raspberry Pi.

Note: By default the installer changes the hostname of your Raspberry Pi to ttn-gateway to prevent any conflicts with any other Raspberry Pi devices on the same network.

Step 4 – Before we setup the gateway on the TTN webpage, you will need to create smallish script, which you can use to reset the gateway. Open up the terminal window and create a bash file with command sudo nano rak831_reset.sh and enter the following:

#!/bin/bash 
echo "17" > /sys/class/gpio/export 
echo "out" > /sys/class/gpio/gpio17/direction 
echo "1" > /sys/class/gpio/gpio17/value 
sleep 5 
echo "0" > /sys/class/gpio/gpio17/value 
sleep 1 
echo "0" > /sys/class/gpio/gpio17/value

Register the Gateway to the TTN network

Step 1 – To get nodes to send data to the cloud through The Things Network you must register yourself with thethingsnetwork.org and follow the instructions to register your gateway device:

https://www.thethingsnetwork.org/docs/gateways/registration.html

Step 2 -Click on “Add new gateways” and fill out the following information in the fields:

Gateway ID: Here add the Gateway EUI number which we noted earlier when installing the software. (This has to be exact)

Description: This can be anything you like for you to have a description of a gateway.

Frequency Plan: This is the frequency of the gateway and should match your gateway. As we’re in Europe I’ve selected the Europe 868Mhz Plan.

Router: This is the closest server to your location, as we’re in Europe I’ve selected Europe but you might find there is a router closer to you.

Location: The location of the gateway is handy to put in, while not required it may be useful in the future and for signal coverage mapping.

Antenna Placement: If the gateway and antenna is indoors then select indoors, if the antenna is mounted externally select outdoors.

All of these settings can be modified later except for the gateway ID

Step 3 – Make sure you hit the “Register Gateway” button at the bottom of the page to save the settings.

 

Now go back to the Raspberry Pi and reboot it. Once you have rebooted go to the command line in the terminal window and type in the following to reset the Gateway:

sudo bash rak831_reset.sh

After a few moment you should now see the blue LED light up on the RAK concentrator board. This indicates that it is activated and connected to the TTN network. You can confirm this by checking the Gateway status in the TTN Console.

Now you can start sending data from your nodes to the Gateway.

Previous article Getting Started with the LoRa Node Arduino Shield
Next article How to assemble your HAT Holder for the Nebra IP67 Case