Skip to content
Artur Balanuta edited this page May 23, 2018 · 27 revisions

This tutorial will show you how to add a LoRa Gateway using a MultiTech Conduit (MTCDT) and a LoRa accessory board (MTAC-LORA) to OpenChirp.

LoPy Image

Create an OpenChirp Device and Generate the Device Token

Please follow the Devices Tutorial to create an OpenChirp Device and Generate a Device Token. You will need the device id, endpoint, and the device token later for configuring the lora-gateway-bridge. Use the LoRa Gateway Template when making your device so you have all of the standard transducers. After you are done setting up your MultiTech Conduit, you will install a LoRaWAN Gateway Service which will take a gateway_ID that is generated from the software running on your MultiTech Conduit.

Prepare the Hardware

Before inserting the LoRa mCard the Operating System and software should be updated.

Install the latest version of mLinux Operating System

Visit Flashing mLinux Firmware for a detailed process on how to update your MultiTech Conduit to the most recent version.

Note: there are pre-built images in the Download Section for your specific Hardware (MTCDT).

Update the Packet Forwarder

Follow the Upgrade Instructions

# Login to mLinux Multitech Conduit
ssh root@<ip address of MTCDT>

# Download the updates
wget http://www.multitech.net/downloads/lora-packet-forwarder_x.x.x-rx.x_mtcdt.ipk
wget http://www.multitech.net/downloads/lora-network-server_x.x.x-rx.x_mlinux.ipk

# Install the updates
opkg install lora-packet-forwarder_*.ipk
opkg install lora-network-server_*.ipk

Versions @ Tutorial:

mLinux 3.3.13 (264)
Lora Packet Forwarder SPI 3.1.0-r9.0
Lora Network Server 1.0.42 (not used, update just in case)

After updating the OS and PF shutdown the device and insert the mCard. Verify that the LoRa mCard was detected using the command: mts-io-sysfs show lora/hw-version

Adjusting the Clock

# Setting the Time Zone, Date, and Time
ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime

# Add local ntp servers to /etc/ntp.conf and restart the service
# (Use a list of ntp server close the LoRa Gateway)
server 0.debian.pool.ntp.org iburst preempt
server 1.debian.pool.ntp.org iburst preempt
server 2.debian.pool.ntp.org iburst preempt
server 3.debian.pool.ntp.org iburst preempt

server new-parsley.srv.cs.cmu.edu  iburst preempt
server new-sage.srv.cs.cmu.edu     iburst preempt
server new-rosemary.srv.cs.cmu.edu iburst preempt
server coriander.srv.cs.cmu.edu    iburst preempt
server fennel.srv.cs.cmu.edu       iburst preempt
server paprika.srv.cs.cmu.edu      iburst preempt

server time.nist.gov preempt

server time1.google.com iburst preempt
server time2.google.com iburst preempt
server time3.google.com iburst preempt
server time4.google.com iburst preempt

server time1.apple.com preempt
server time2.apple.com preempt
server time3.apple.com preempt
server time4.apple.com preempt
server time5.apple.com preempt
server time6.apple.com preempt
server time7.apple.com preempt

# Restart the service
/etc/init.d/ntpd restart

# Check if the servers are used and if the time has been adjusted 
ntpq -pn
date

# Update the hardware clock
hwclock -u -w

Packet Forwarder Configuration

Follow the Conduit mLinux: Convert to Basic Packet Forwarder setup guide. Determine the hardware version of the LoRa mCard (mts-io-sysfs show lora/hw-version). Tutorial LoRa mCard's Version: MTAC-LORA-1.5

/etc/init.d/lora-network-server stop

# Edit /etc/default/lora-network-server
ENABLED=”no”

# Edit /etc/default/lora-packet-forwarder
ENABLED=”yes”

# Copy the configuration file (in our case the MTAC-LORA-1.5 and US915 Region) 
wget <link to text file> -O /var/config/lora/global_conf.json

# Get the device Device_ID from the LoRa EUI
mts-io-sysfs show lora/eui | sed -e 's/://g'

# Configure the /var/config/lora/local_conf.json file and replace the gateway_ID with LoRa EUI
{
 "gateway_conf": {
    "gateway_ID": "<INSERT-LORA-EUI-HERE>",
    "server_address": "localhost",
    "serv_port_up": 1700,
    "serv_port_down": 1700
    }
}

# Enable start-up on boot
update-rc.d lora-packet-forwarder defaults 80 30

# Enable logging (/etc/init.d/lora-packet-forwarder)
# change "exec $pkt_fwd" to "exec $pkt_fwd > $pkt_fwd_log 2>&1" on line 126

# Start packet forwarder using this command
/etc/init.d/lora-packet-forwarder start

# Check if the process is running
ps -faux | grep lora

Install the LoRa Gateway Bridge

Download the latest release of the precompiled LoRa Gateway Bridge Binary (lora-gateway-bridge_x.x.x_linux_arm.tar.gz) from the OpenChirp Custom Gateway Bridge into the /opt/lora/ folder.

Tutorial version: lora-gateway-bridge 2.1.5-23-gdc983b1

# Download it    
wget https://github.com/OpenChirp/lora-gateway-bridge/releases/download/OC-x.x.x-xx/lora-gateway-bridge_x.x.x-xx-xxxxxxxx_linux_arm.tar.gz

# Decompress it
tar -xf lora-gateway-bridge_*_linux_arm.tar.gz
rm lora-gateway-bridge_*_linux_arm.tar.gz

# Create and complete the default configuration file
nano /etc/default/lora-gateway-bridge

Configure the gateway bridge service by modifying /etc/default/lora-gateway-bridge. Please set the following parameters as indicated:

  • MQTT_SERVER="tls://mqtt.openchirp.io:1883"
  • MQTT_PREFIX="<your_openchirp_device_endpoint> available on the OC website for your device"
  • MQTT_USERNAME="<your_openchirp_device_id> which is the last 24 digits, number part, of the endpoint"
  • MQTT_PASSWORD="<your_openchirp_device_generated_token>"

<your_openchirp_device_endpoint>, <your_openchirp_device_id>, and <your_openchirp_device_generated_token> should be replaced based on your OpenChirp device you created earlier.

The init file and example configuration can be found here.

# Create init file and enable boot at startup
nano /etc/init.d/lora-gateway-bridge
chmod +x /etc/init.d/lora-gateway-bridge
update-rc.d lora-gateway-bridge defaults
/etc/init.d/lora-gateway-bridge start

# If error occurs verify if the init file was correctly copied,
# 'newline symbols' may have been introduced

# Check if the process is running
ps -faux | grep lora

# Check process log in /var/log/*

Logging

# Configure Logrotate to delete old lora-gateway-bridge logs
echo "/var/log/lora-gateway-bridge.log {
    size 512k
    rotate 4
    compress
    copytruncate
    missingok
}" > /etc/logrotate.d/lora-gateway-bridge.conf


# Stop and remove unused Services
/etc/init.d/mosquitto stop
update-rc.d -f mosquitto remove

OpenChirp

Using the OpenChirp.io website, navigate to your previously created OpenChirp Device. Navigate to the Services tab and click Link Service. Select LoRaWAN Gateway, input your gateway_ID, and click Save. After refreshing the page, you should see a status that indicates your gateway was registered with the provided ID.

You may also want to add the TimeSeries service for visualizing debug data over time.

Fake GPS coordinates

Edit /var/config/lora/local_conf.json

add fake_GPS options:

{
 "gateway_conf": {
     "gateway_ID": "xxxxxxxxxxx",
     "autoquit_threshold": 5,
     //"gps_tty_path": "/dev/ttyAMA0",
     "server_address": "localhost",
     "serv_port_up": 1700,
     "serv_port_down": 1700,
     "fake_gps": true,
     "ref_latitude": 40.244362,
     "ref_longitude": -79.519109,
     "ref_altitude": 0
 }
}