You are on page 1of 7
sepia Hes-so Haute école du paysage, d’ingénierie Haute Ecole Spécialisée et darchitecture de Geneve : Je Wostechwe'e Laboratoire de systémes numériques University of Applied Sciences F, Vannel, D. Da Silva Andrade, A. Upegui wes fond Setting up your own LoRaWAN gateway IoT - HES-SO Master 2016 - 2017 Winter Semester Objectives The goal of this laboratory is to set up a LoRa gateway using a Raspberry Pi and a LoRa concen- trator. The data captured by our gateway will be available using The Things Network (TTN) MQTT server. 1 Introduction Preliminary note : all the technical Libelium documentations that may be used for these labs are available on Cyberlearn https: //cyberlearn.hes~so.ch/mod/folder/view.php?id=626981 Also refer to the previous lab for others references. In this lab you will discover how to set up your own LoRaWAN gateway based on a iC880A LoRaWAN concentrator and a Raspberry Pi. The Raspberry Pi communicate with the iC880A using an SPI interface. The concentrator use the Semtech $X1301 chip that is able to listen at 8 LoRa frequencies at the same time and can then decode simultaneous LoRaWAN communi- cation received by multiple devices. Received LoRaWAN packets will be forwarded by your gateway to the The Things Network (TTN). TIN is a community solution which aim is to develop a LoRaWAN network at the world size, then avoiding borders limitations. Using there services if currently free. TTN can be seen as a concurrent solution to Swisscom LPN, but deployment depends only of people interested in the LoRa technologies and unfortunately at this time no service guaranties can be expected from TTN, 1.1 Hardware For this lab, you'll be given the following hardware : — 1 Waspmote with the LoRaWAN module — 1 LoRa Gateway : Raspberry Pi + iC880A (LoRaWAN concentrator 868MHz) — 2868MHz antennas — 15V/2.5A micro USB power supply 12 Software You will need to use an SSH client to access the Raspberry Pi. On GNU Linux or OS X system you can directly use it from your terminal. If you are on Windows you can use Putty. To program the Waspmote Pro you will need the Waspmote Pro IDE. Please follow the instruc- tions provided on the previous laboratory (Introduction to LoRa) to set it up correctly. 2 Connecting the gateway The Raspberry Pi 3 has two ways to access the Internet ; a WiFi interface or a wired one. In this, practical work we will use the WiFi to access the Internet and the wired interface to configure the gateway. Since the Eduroam is a bit clumsy in Provence we set up a WiFi hotspot with the following authentication : SSID : hepiaWiFi Password : hepialoT You will need to access to Raspberry Pi first to set up the correct WiFi network. We need to connect everything like illustrated with the Figure 1. We pre-configured for you the eth0 inter- face with the static ip 192. 168.1. 32. You can use an SSH client to connect to the Raspberry Pi with the following command : $ ssh pi@192.168.1.32 password : hepialoT <> internet ee FIGURE 1. Network connection 2.1 WiFi configuration By default the WiFi accessed is the hotspot provided in class. If you want to access your own WiFi you need to edit the /wpa_supplicant /wpa_supplicant .conf with your own configuration : network: "The_SSID_of_your psk="Your_wifi_password Ensure that you're connected to the Internet with a ping. If it’s not the case, try to restart the Raspberry Pi without any cable Ethernet connected. Wait 30s and then plug back your Ethernet cable. Reconnect a new SSH connection and retry with a new ping, it should work now. If it's still not the case, ensure that your WiFi configuration is correct. 3 Connecting your gateway to The Things Network 3.1. Packages required Once you are connected you will need to install git to retrieve the gateway software that is hosted on GitHub : $ sudo apt-get update $ sudo apt-get install git 3.2. LoRa concentrator access Note : in this section you don't need to download the HAL nor the packet forwarder project. This section is here for you to understand what will be installed when using the script provided by The Things Network platform. The LoRa technology is mainly developed by a company named Semtech. They are the only company authorised to develop LoRa compatible chips A example of communication is illustrated by the Figure 2. A node will send data through their LoRa chip, in our case the node will be a Waspmote PRO with a Microchip RN2483 module. The LoRa communication is then received by the iC880A concentrator that will communicate with the host using a USB or SPI interface. In our case, the host is a Raspberry Pi gateway. Data is then sent to a server using a TCP/IP link. Once data is stored on the server, it can be accessed with any API available by the server, in our implementation it will be through MOTT or Nodejs, customer de Gateway FIGURE 2. Basic system: concept Semtech provide a HAL (Hardware Abstraction Layer) to communicate with their different chips. Semtech only has one concentrator chip at the moment named SX1301 https://github.com/Lora-net /lora_gateway In this HAL you can find multiples drivers (SPI and USB) for their SX1301 chip. A few tools are also available to test if your concentrator is working as expected. With this HAL you can access 3 the LoRa antenna and log everything in local, but if you want to send it to a server you need a program that will listen on the RF channels and send back information to a server. Semtech also provide a program that do this job, it’s called packet forwarder : https: //github.com/Lora-net/packet_forwarder The packet forwarder is a program running on the host of a Lora gateway that forwards RF packets receive by the concentrator to a server through a IP/TCP link, and emits RF packets that are sent by the server. More information can be found on the iC800A integration with a Raspberry Pi on the IMST website. They have a quick-start guide that explain you how to set up and access directly the hardware on the iC880A board with a Raspberry Pi http: //www.wireless-solutions.de/images/stories/downloads/Radio& 20Modules/iC880A/iC880A~SPI_QuickStartGuide.pdf 3.3 The Things Network ‘The Things Network provide an script to install everything required to connect to their service. It has a installation script that will automatically download 3 projects : 1. wiring? : library used to control GPIO on a Raspberry, it's required to control the reset pin on the iC880A. 2. Semtech HAL lora-gateway : Hardware Abstraction Layer for the SX1301 chip. 3. Packet forwarder by The Things Network : packet forwarder project modified to connect and send data from a gateway to their network. First, you need to download the installer with the following command : $ed $ git clone -b spi https :/ /github.com /ttn-zh /ic880a-gateway.git Once the download is achieved, you can start the installation script $cd /ic880a-gateway $ sudo ./install.sh spi During the installation a few questions will be asked to you, respond as follow Not : Replace by your last names $ sudo ./install.sh spi The Things Network Gateway installer Version Updating installer files Already up-to-date. Gateway configuration: Detected EUI B827EBFFFEDC7BB9 from eth Do you want to use remote settings file? [y/NIN Host name [ttn—gateway ]: ttn gateway — Descriptive name [ttn—ic880a | Contact email: Latitude [0]: Longitude [0]: Altitude [0]: If the installation is achieved successfully, then you should see these last lines : 4 Gateway EUI is: and a brief description. 4.1 Enrol a new device with your application Once your application is created, you can assign new devices to your application. In our case the new device will be a Waspmote PRO with a LoRaWAN module. To create new devices just click on the register device link on the application page under the menu DEVICES. Enter a ID that will define your device, for example, waspmote_0. You can define the device EUI or you can generate a new EUI with the random button on the left, just choose one of these two options. To create your device just press the Register button. In our case, we will use ABP assignation and let The Things Network generate our Network and App Session Key. By default, the device created is a OTAA (Over-the-Air Activation), to change it to an ABP configuration you need to access his settings. From the device page click on the settings button on the top right of the page. Selection the Activation method to be ABP, then just press the save button to generate everything, At the end of this process you should have a device like the one illustrated on the Figure 3 (of course with different EUIs and addresses). Avolemiont > ©) et 2016.17.0 > Deser > aerate 0 Data setins DEVICE OVERVIEW AeptentenI i 2034.079 Dome memiareazeokorer 8 ArplenionEUl OMS TEFEGO TB DekeAties Oo ommBG 8 NeworkSenionkey 0 & . povsenionkey 0 ee 5 Figure 3. ABP device created on the The Things Network platform 4.2. Configure your Waspmote Now your Waspmote PRO must be configured with the EUIs assigned to your device equip- ped with a LoRaWAN module. You will need to copy the DEV EUI, the Dev Address, Network Session Key and App Session Key to a device accessing a LoRaWAN network using ABP. Note : To have the best performance for this lab with your device, you should configure it with the a SE7BW125 datarate and a coding rate of 4/5. You can use a reduced TX power, but in case of problem set-up the TX to 14 dBm (max power). 4.3 Retrieve data from application 43.1 Using the web interface To ensure that your device is working, you can return to your application home page and select the menu Data, You will find an array with everything that will be sent on the network. You should have something like illustrated on the Figure 4. APPLICATION DATA 8 cabs uplink down activation eae cor port devi pond fds ‘A 35:01:23 20503 waspmate.0 6162 030805 06 G7 8 89 aA 88 OC 8D BE OF > A s5i8ls1L 2009 3 waspmote. 616203 64 OF 6 8708 69 Ok 0B 8c 80 8F > ‘A ss:08-58 2049 3 waspmate.0 61 62 030805 06 G7 8 89 aX 88 a 8D 8E BF > FIGURE 4. Data from devices using the web interface 43.2 Using MOTT client To retrieve data from your application we will use the MQTT service provided by The Things Network, The API documentation and a quick start guide to how to access the MQTT server using mosquitto can be found on this link : www thethingsnet work .org/docs/applications/matt /quick-start .htm) NOTE : There is an error in some examples given on the API website when using the mos- quitto client. It will not work if you specify the port in the broker URL. The correct URL eu. thethings. network, without the’: 1883" at the end. 43.3. Using Nodejs client You can also use their Node js client if you want to retrieve data from your application. Eve- rything covering the installation, live examples and API documentation can be found on the following link https: //www. thethingsnetwork.org/docs/applications/nodejs/ 5 What to do if your Raspberry Pi is misconfigured (Just in case...) You can always flash the SD card with our base image configured with a s and an SSH server. First download our image using the following link atic ip on the ethO https: //drive.switch.ch/index.php/s/VWHk£3DYAaxF7r0 You then will need to copy it to the SD card, start by connecting it to your laptop using a SD card reader. If you are on GNU Linux/OS X you can use the dd command to copy the image = gzip -de .gz | py | sudo dd bs~4M of-/dev/mmcb1k0 Note : please be careful with the dd command ! Be sure of your partition choice before using the command, the output partition is defined by the of parameter. Ifyou are on windows, please follow the instructions on this link: https: //www. raspberrypi . org/document at ion/installation/installing-images/windows.md

You might also like