DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • A Deep Dive Into Firmware Over the Air for IoT Devices
  • Optimizing IoT Performance in Industrial Environments
  • IoT Needs To Get Serious About Security
  • Operational Technology Cybersecurity for Automotive Industry: Learnings From an IBM OT Security Architect

Trending

  • Assessing Bias in AI Chatbot Responses
  • Mastering Deployment Strategies: Navigating the Path to Seamless Software Releases
  • How Can Developers Drive Innovation by Combining IoT and AI?
  • Navigating Double and Triple Extortion Tactics
  1. DZone
  2. Data Engineering
  3. IoT
  4. Contributing an IoT LoRaWAN Raspberry Pi RAK831 Gateway to the Things Network

Contributing an IoT LoRaWAN Raspberry Pi RAK831 Gateway to the Things Network

Learn more about connecting your LoRaWAN Raspberry Pi to the Things Network.

By 
Erich Styger user avatar
Erich Styger
·
Mar. 04, 19 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
16.7K Views

Join the DZone community and get the full member experience.

Join For Free

LoRa and LoRaWAN are getting the de-facto wireless IoT network in my area. It's no surprise that traditional telecom providers like Swisscom try to monetize the IoT sector. Luckily, there is an open and free alternative: https://www.thethingsnetwork.org/. Volunteers, enthusiasts, and members in the different TTN communities build gateways and offer free LoRaWAN network access. I wanted to contribute to that grassroots movement with building my gateway, providing LoRaWAN access to my neighborhood.

LoRaWAN TheThingsNetwork Gateway

LoRaWAN TheThingsNetwork Gateway

TheThings Network LoRaWAN Gateways in Switzerland

TheThings Network LoRaWAN Gateways in Switzerland

RAK831 Semtech SX1301 LoRaWAN Gateway Module

RAK Wireless sells the RAK831 module:

Application Diagram

Application Diagram (Source: Rakwireless.com)

As a host, I’m using a Raspberry Pi, which then will be able to act as a multi-channel LoRaWAN gateway supporting 10 channels (8 downlink, 1 uplink, and 1 FSK channel). The GPS module is used as a timestamp interface for the SX1301.

The Kit

I ordered my RAK831 868 MHz kit from AliExpress without a Raspberry Pi. I’m using it with a Raspberry Pi 3 Model B V1.2.

RAK831 Kit Content

RAK831 Kit Content

The LoRA and the GPS module are connected with an antenna cable:

RAK831 Modules

RAK831 Modules

I opted for the kit with the external GPS antenna and the aluminum enclosure with a heat sink. To fit the LoRa Gateway module into the case, the two sides brackets of the gateway PCB need to be removed.

Never (never!) power the gateway without the antenna attached; otherwise, it might burn the transceiver!

Raspberry Pi Setup

I assume basic knowledge about how to set up a Raspberry Pi: set up your system with a recent distribution.

I do not recommend to fully assemble the enclosure during software installation, as otherwise the LED of the LoRa board cannot be monitored:

Pi with Gateway

Pi with Gateway

Because the Semtech chip produces a lot of heat that blue heat transmission material is placed on top of the heat-sink via’s to transmit the heat to the enclosure.

Enable SPI

The Raspberry Pi gateway software communicates with the LoRa transceiver. The SPI peripheral is not turned on by default. To enable it, do the following.

  • run ‘sudo raspi-config’
  • Select ‘Interfacing Options’Interfacing Options

    Interfacing Options

    Select ‘SPI’:SPI

    SPI

    Select ‘yes’ to enable SPI:Select SPI

    Select SPI

  • Confirm as well with ‘yes’ if it asks to automatically load the kernel module.
  • Then, exit and finish the dialog
  • reboot
  • Installing Gateway

    First, get a general update:

    sudo apt-get update && sudo apt-get upgrade && sudo apt-get install git -y


    Next, cd to the user account

    cd ~


    Clone the gateway from git:

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


    cd into that directory:

    cd ic880a-gateway


    Reset Pin

    By default, the gateway is using pin 25 to reset the gateway. This was the reason why I was not able to use the gateway out of the box; it took me a while to realize. So, change the reset pin setting from pin 25 to 17! There are actually two scripts: one in ~/ic880a-gateway/start.sh and one in /opt/ttn-gateway/bin/start.sh. Both files need to be modified!

    The one in the ic880a-gateway folder can be modified right away and is copied to /opt/ttn-gateway/bin/start.sh during installation.

    Reset pin number in start.sh

    Reset pin number in start.sh

    Setup

    Run the script inside the ic880a-gateway folder:

    sudo ./install.sh


    It shall report the EUI number: write it down or copy it:

    EUI

    EUI

    Now, stop here for a while. First, we need to set up the TTN side. Register for a The-Things-Network (TTN) account.

    Then, go to the ‘Console’ area on your TTN account where you can register a new gateway. Enter all the information, but make sure you select ‘I’m using the legacy packet forwarder.’ And now, we have to enter that EUI number we noted in the previous step:

    Legacy Packet Forwarder

    Legacy Packet Forwarder

    Fill out the other fields, e.g.:

    Register Gateway

    Register Gateway

    Remember the GPS coordinates as you will need them on the Raspberry Pi for initial setup, then proceed with the registration with pressing ‘N.’ Then, enter all the information:

    Continue Setup

    Continue Setup

    The information entered gets stored in /opt/ttn-gateway/bin/local_conf.json. In that same folder, there is a global_conf.json, which configures the other parts of the gateway.

    In the end, the machine gets rebooted. Don’t forget to verify the reset pin number in /opt/ttn-gateway/bin/start.sh!

    Reboot and check the logs with:

    systemctl status ttn-gateway.service


    It should report something like this:

    Feb 24 17:20:29 LoRaWanGW ttn-gateway[356]: INFO: [down] for server router.eu.thethings.network PULL_ACK re
    Feb 24 17:20:29 LoRaWanGW ttn-gateway[356]: ##### 2019-02-24 16:20:29 GMT #####
    Feb 24 17:20:29 LoRaWanGW ttn-gateway[356]: ### [UPSTREAM] ###
    Feb 24 17:20:29 LoRaWanGW ttn-gateway[356]: # RF packets received by concentrator: 0
    Feb 24 17:20:29 LoRaWanGW ttn-gateway[356]: # CRC_OK: 0.00%, CRC_FAIL: 0.00%, NO_CRC: 0.00%
    Feb 24 17:20:29 LoRaWanGW ttn-gateway[356]: # RF packets forwarded: 0 (0 bytes)
    Feb 24 17:20:29 LoRaWanGW ttn-gateway[356]: # PUSH_DATA datagrams sent: 1 (241 bytes)
    Feb 24 17:20:29 LoRaWanGW ttn-gateway[356]: # PUSH_DATA acknowledged: 100.00%
    Feb 24 17:20:29 LoRaWanGW ttn-gateway[356]: ### [DOWNSTREAM] ###
    Feb 24 17:20:29 LoRaWanGW ttn-gateway[356]: # PULL_DATA sent: 3 (100.00% acknowledged)


    At the end, and with yet another reboot, the RX LED shall now be on:

    Success LED is ON

    Success LED is ON

    Check the status of the gateway in the TTN Router console:

    Gateway Overview

    Gateway Overview

    Congratulations, you have a LoRaWAN gateway!

    Monitoring TCP Port 1700

    A good way to check that everything is working is to use ‘tcpdump.’ If not already installed, install it with:

    sudo apt-get install tcpdump


    Then, I can monitor the traffic with

    sudo tcpdump -AUq port 1700


    which should show something like this:

    tcpdump

    tcpdump

    Another good way to verify the system is to check the syslog:

    sudo tail -f /var/log/syslog

    invalid gps time

    invalid gps time

    As seen above, my GPS is not configured properly, so this is something I have to cover next.

    GPS

    For me, the GPS module was attached to ttyS0. Use the following to see the NMEA messages coming in:

    sudo cat /dev/ttyS0


    Which should show some GPS messages coming.

    What is missing is that the messages are consumed to the gateway. For this, I have to edit the /opt/ttn-gateway/bin/global_conf.json configuration file. Below what I had installed:

    original GPS configurationoriginal GPS configuration

    I changed this to:

    /* GPS configuration */
    "gps_tty_path": "/dev/ttyS0",
    "fake_gps": false,
    "ref_latitude": 10,
    "ref_longitude": 20,
    "ref_altitude": -1,


    The other thing is that I have to disable the login Shell on the UART. This is a setting in the configs:

    sudo raspi-config


    then Interfacing Options:

    Interfacing Options

    Interfacing Options

    Then, select Serial:

    Serial config

    Serial config

    Disable the Login Shell:

    login shell disabled

    login shell disabled

    With the Serial Port Hardware enabled:

    serial hw port enabled

    serial hw port enabled

    Then, confirm and reboot. Login Shell is disabled and the interface is enabled. And now, I have a working GPS:

    Login shell disabled and interface enabled

    Working GPS

    Working GPS

    Summary

    Contributing to an open-source and community network is a fun learning experience. The gateway is now working for several days and is handling LoRaWAN packets from my neighborhood. The next step is to attach a long fiberglass antenna and put that gateway with a fiberglass antenna on top of my house for a larger coverage

    Happy LoRaWANing!

    Helpful Links

    • What is LoRa?
    • RAK Wireless
    • http://support.rakwireless.com/
    • https://www.raspberrypi.org/
    • https://www.thethingsnetwork.org/labs/story/rak831-lora-gateway-from-package-to-online
    • RAK831
    • https://www.hackster.io/naresh-krish/getting-started-with-the-rak831-lora-gateway-and-rpi3-e3351d
    • RAK831 on AliExpress: search for “Lora Gateway Concentrator Module Kit, RAK831, base on SX1301, 433/470/868/915MHz, Wireless Spread Spectrum Transmission”
    • https://www.hackster.io/rak-wireless/rak831-raspberry-pi3-gateway-and-rak811-loranode-user-manual-748f5b
    • The Things Network
    • Detect the GPS module of the official RAK831 shield for Raspberry Pi 3.
    • TTN Mapper
    raspberry pi Network IoT

    Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

    Opinions expressed by DZone contributors are their own.

    Related

    • A Deep Dive Into Firmware Over the Air for IoT Devices
    • Optimizing IoT Performance in Industrial Environments
    • IoT Needs To Get Serious About Security
    • Operational Technology Cybersecurity for Automotive Industry: Learnings From an IBM OT Security Architect

    Partner Resources

    ×

    Comments
    Oops! Something Went Wrong

    The likes didn't load as expected. Please refresh the page and try again.

    ABOUT US

    • About DZone
    • Support and feedback
    • Community research
    • Sitemap

    ADVERTISE

    • Advertise with DZone

    CONTRIBUTE ON DZONE

    • Article Submission Guidelines
    • Become a Contributor
    • Core Program
    • Visit the Writers' Zone

    LEGAL

    • Terms of Service
    • Privacy Policy

    CONTACT US

    • 3343 Perimeter Hill Drive
    • Suite 100
    • Nashville, TN 37211
    • support@dzone.com

    Let's be friends:

    Likes
    There are no likes...yet! 👀
    Be the first to like this post!
    It looks like you're not logged in.
    Sign in to see who liked this post!