This project is an extension to the original Rpi 3 Based concentrator project using the awesome RAK831 concentrator board made by RAK Wireless. There are some quirks to getting the board working with RAK831 and I intend to guide you along the way and hopefully provide some debugging tricks to solve common issues
You can checkout the original project here:
https://www.hackster.io/naresh-krish/getting-started-with-the-rak-831-lora-gateway-and-rpi3-e3351d
The Hardware SetupThe RAK831 board is just a concentrator board, It provides the frontend modules required to communicate with lora wan node modules and hence needs a main board to send the SPI commands.The SX1301 is the main main chpset used in the RAK831 along with 2 sx1257 modules as the frontend chipsets. The SX1301 is capable of handling the communication to the RPi via SPI and the HAL code hosted by Semtech is useful to get your RAK831 up and running on a supported linux board
Semtech repo:
https://github.com/Lora-net/lora_gateway
Note:
1) Make sure that you buy the correct lora frequency version of the RAK831 board as supported in your country. Not all countries allow all the lora frequencies for transmission and it is better to talk to your local authorities on the laws and which frequencies are allowed as un-licensed bands for legal operation
Before we begin lets get a few checklist items ticked off
- 1) A good 5v, 2000mA power supply to power the pi and the RAK831
- 2) Short enough dupont jumper cables (not mopre than 15-20 cms) or use the RAK converter board as provided in the things required sections.
- 3) make sure that the antennae provided in the rak831 package is connected to the concentrator bord before powering it on. THIS IS A MUST !!!!!
Pin connection:
Here is the pin connection between the RpI zero w and the RAK831 board
Now that we have all that oput of the way lets begin with the installation.
Setting up Wifi on the RPi Zero W- Insert your SD card with Raspbian into it into your computer and open the SD card from your file explorer - the drive will be labelled boot.
- Within the boot directory, Right-Click > New > Text Document and rename the document to wpa_supplicant.conf - Make sure that you change the file extention from .txt to .conf - You will be prompted to confirm the extension change.
- With the empty file created, Right-Click on it an select open. You may be prompted to select a program you'd like to open the file with - just choose Notepad.
This is where we enter our WiFi details. Enter the following text into the file, replacing the placeholder text with your own details.\
network={
ssid="SSID"
psk="password"
key_mgmt=WPA-PSK
}
ENABLE SSH
By default, the current version of Raspbian has SSH disabled. We're going to enable it here.
Create an empty file in the boot directory called ssh
Make sure that the file has no file extension, i.e. remove the .txt if you created the file by selecting New > Text File.
Your Pi is now ready for startup. Eject the SD card from your computer and insert it into your Pi. Power up your Pi and wait a few moments for the initial boot to complete. On your computer, open up PuTTY.
And now you can use an app like angry IP scanner or Fing (Android app) such to scan for all the devices in your wifi network. Choose the IP that eithewr of the Apps show up as raspberry pi and ssh into the pi
Username: Pi
Password: raspberry
Note:
It is always a good practice to chnage the default practice of the pi user to a something else rather than keeping the default one. Since the rpi zero in this case is being used as gateway , i would HIGHLY RECOMMMEND to chnage the password immediately using the passwd command followed by the pi username
$ passwd pi
This will prompt you for the current password and then ask you to set the new password. Simple but provides safety :)
Setting up the gateway software:Once your raspberry pi and Rak831 combo is up and running, its time to get the software running.
On the Raspberry pi lets do the following steps to get the essential software installed:
- Enable SPI:
Use raspi-config utility to enable SPI ([5] Interfacing options -> P4 SPI) and also expand the filesystem ([7] Advanced options -> A1 Expand filesystem):
$ sudo raspi-config
- Make sure git is installed
Sudo apt-get update
Sudo apt-get upgrade
Sudo apt-get install git
- Manage your wifi connection on the raspberry pi
- Configure the wifi credentials (check here for additional details)
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
And add the following block at the end of the file, replacing SSID and password to match your network:
network={
ssid="The_SSID_of_your_wifi"
psk="Your_wifi_password"
}
- Clone the installer and start the installation
$ git clone -b spi https://github.com/ttn-zh/ic880a-gateway.git ~/ic880a-gateway
$ cd ~/ic880a-gateway
$ sudo ./install.sh spi
- The installation step will ask you if you want to enable remote configuraton. Type ‘y’ or ‘yes’ and continue with the installation. At the start of the command line install, the script would show you the gateway EUI which is important for the next steps. NOTE IT DOWN !
- If you want to use the remote configuration option, please make sure you have created a JSON file named as your gateway EUI (e.g. B827EBFFFE7B80CD.json) in the Gateway Remote Config repository here: https://github.com/ttn-zh/gateway-remote-config. Fork the repo, add your <EUI>.json file with the proper configuration and then commit the forked repo. Once done, send a pull request to the master repo and the file should show up in the repo the next day. A sample json is shown below:
{
"gateway_conf": {
"gateway_ID": "the id as you noted down in the install.sh console output",
"servers": [
{
"server_address": "the router to which you want to connect to",
"serv_port_up": 1700,
"serv_port_down": 1700,
"serv_enabled": true
}
],
"ref_latitude": the lat of the rak 831 gateway,
"ref_longitude": the long of the rak 831 gateway,
"ref_altitude": 40,
"contact_email": "contact email of the gateway owner",
"description": "a short desciption"
}
}
Note:
For a list of valid routers check the link here:https://www.thethingsnetwork.org/wiki/Backend/Connect/Gateway
- By default, the installer changes the hostname of your Raspeberry Pi to ttn-gateway (to prevent collisions with other Raspberry Pis in your network). You can override this in non-remote configuration mode.
- HURRAY your gateway should now work. Make sure you restart the gateway the next day for your json file to be downloaded properly to the RPi3.
When ever we start the raspberry pi, it is a good practice to reset the attached RAK831 lora module. There are two ways to do it:
- Via Shell script:
A small shell script can be written to reset the RAK831 before the LoRa driver can access the hardware. The content of the shell script can look like the following example (which assumes that the GPIO 17 (pin 11) of the Raspberry Pi is connected to the reset pin of the RAK831):
#!/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
These lines can be stored in a file called “rak831_reset.sh”. The user must call this script once after every boot up in order to get the concentrator IC in a clean state.
- Via Wiring pi:
If the host system is a Raspberry Pi the user can write a small C-Tool to reset set the RAK831. In order to access the GPIO pins of the Raspberry Pi there is a library called “wiringPi” that takes care of the low level details. The library can be downloaded from http://wiringpi.com. Please refer to this site to get installation and usage instructions. The content of the RAK831_reset.c file can look like the following:
#include <wiringPi.h>
#include <unistd.h>
#define GPIO_RESET_PIN 0 // see wiringPi mapping!
int main() {
wiringPiSetup();
pinMode(GPIO_RESET_PIN, OUTPUT);
digitalWrite(GPIO_RESET_PIN, HIGH);
sleep(5);
digitalWrite(GPIO_RESET_PIN, LOW);
return;
}
The user must call this tool once after every boot up in order to get the concentrator IC in a clean state.
gcc -Wall -o blink blink.c -lwiringPi
sudo ./blink
Register the gateway to the TTn network:To get your nodes to send data to the cloud TheThingsNetwork provides a cloud service to parse and store the data sent by lora nodes via a lora gateway. You need to register yourself with the thethingsnetwork.org and follow the instructions to register your gateway:
https://www.thethingsnetwork.org/docs/gateways/registration.html
Once the gateway is registered you would see the gateway console page like so:
courtesy TheThingsNetwork.org
courtesy TheThingsNetwork.org
Troubleshooting the gateway:If your not able to see the RX light on the RAK 831 turn red check the following:
- Make sure your <EUI>.json file is commited in the github repo https://github.com/ttn-zh/gateway-remote-config
- If you enter the following commands
- a.
sudo tail /var/log/syslog
-- when it is online, you will see messages from the TTN-Gateway (might need to look beyond the last few lines).
- Make sure your connections are good and that the RAK 831 power supply LED is bright RED. <DIG>
- On the gateway UI page in the TTN website make sure te gateway shows up as connected.
Power rail issues:
- It is important to note that you need to use a good 5v, 2000ma power supply to power up this concentrator combo for reliable performance.
- Also make sure that if your powering up from a power supply directly using its power rail and ground pin/socket, you have to tie the grounds of the power supply, RPi and the RAK831 together for successful connection.
Connection issues:
- make sure that the grounds of the rpi and rak831 are tied together
- try to run the utils_tx_test and the test_loragw_spi and test_loragw_reg to make sure that your concentrator is running correctly without errors
- When in development mode, also do switch on the debuggin for the HAL and SPI modules of the gateway code to DEBUG. You can do this by setting the following constants to 1 in the library.cfg file in the repository mentioned above DEBUG_SPI= 1, DEBUG_REG= 1, DEBUG_HAL= 1
Comments