Introduction

I decided to build a LoRa gateway.

After doing a bit of research, I decided to build the gateway using Raspberry Pi & Multitech mCard per this tutorial.

Once I have the gateway up & running, I can start doing further R&D work in the LoRa space.

Parts

  • 1 x Raspberry Pi 3 Model B V1.2
  • 1 x Multitech mCard LoRa 868MHz (MTAC-LORA-868)
  • 1 x USB to Mini PCIe converter
Raspberry Pi Model B V1.2 Multitech mCard LoRa 868MHz (`MTAC-LORA-868`) USB to Mini PCIe converter

USB to Mini PCIe converter modification for mCard

As per the tutorial, pins 23 and 25 need added 5V supply from the USB connector.

I checked the PCI Express Mini Card (Mini PCIe) pinout page so I know what I am doing.

The following two photos show how I intend to do the modification of the converter.

Diagram of USB to Mini PCIe converter modification for mCard Diagram of USB to Mini PCIe converter modification for mCard

I soldered a small piece of wire, first to pins 23 & 25 and then to the VCC pin of the USB connector.

Finished modification of USB to Mini PCIe converter for mCard

Raspberry Pi Setup

I decided to use Ubuntu MATE as my distribution for the Raspberry Pi.

I downloaded MATE and put it on a new micro SD card in a similar fashion like I previously setup my brew station with Debian Jessie.

When MATE starts for the first time, it prompts for initial setup (timezone, language, computer name and initial user with encrypted home dir) and then sets itself up. Very smooth.

Once ready, I could log as the user I created during the setup.

Then I ran an upgrade, which took a while:

$ sudo su -
$ apt-get update
$ apt-get upgrade
$ reboot

Then I resized the file system via System -> Welcome -> Raspberry Pi Information screen.

There are also some good information on that page about rpi-update and graphical enable|disable commands. Worth a read.

Then I ran rpi-update and disabled the graphical interface:

sudo su -
rpi-update
graphical disable
reboot

Installed basic packages:

sudo su -
apt-get install vim
apt-get install screen

I checked ifconfig to see what the status is:

root@lora-gateway-mk1:~# ifconfig
enxb827eb675682 Link encap:Ethernet  HWaddr b8:27:eb:67:56:82
          inet addr:192.168.1.5  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::ba27:ebff:fe67:5682/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:88311 errors:0 dropped:0 overruns:0 frame:0
          TX packets:23546 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:131505477 (131.5 MB)  TX bytes:1924542 (1.9 MB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:3556 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3556 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:282472 (282.4 KB)  TX bytes:282472 (282.4 KB)

I setup static IP address and nameservers in /etc/network/interfaces:

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

# The loopback network interface
auto lo
iface lo inet loopback

auto enxb827eb675682
iface enxb827eb675682 inet static
address 192.168.1.134
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.8.4

LoRa Gateway Software Setup

SPI

I enabled SPI in /boot/config.txt:

dtparam=spi=on

Then I ran reboot to get SPI enabled.

After the reboot, SPI appeared:

$ ls /dev/spi*
/dev/spidev0.0  /dev/spidev0.1

FTDI & libmpsse

$ sudo su -
$ apt-get install git
$ apt-get install libftdi-dev
$ wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/libmpsse/libmpsse-1.3.tar.gz
$ tar xvfz libmpsse-1.3.tar.gz
$ cd libmpsse-1.3/src
$ ./configure --prefix=/usr --disable-python
$ make
$ make install
$ cd /etc/udev/rules.d/
$ wget https://raw.githubusercontent.com/mirakonta/lora_gateway/master/libloragw/99-libftdi.rules
$ udevadm control --reload-rules
$ udevadm trigger
$ adduser lg plugdev

LoRa gateway & packet_formarder

$ mkdir -p lora/exec
$ cd lora
$ git clone https://github.com/mirakonta/lora_gateway.git
$ git clone https://github.com/mirakonta/packet_forwarder.git
$ cd ~/lora/lora_gateway
$ make clean all
$ cd ~/lora/packet_forwarder
$ make clean all
$ cp ~/lora/packet_forwarder/basic_pkt_fwd/basic_pkt_fwd ~/lora/exec/
$ cp ~/lora/packet_forwarder/basic_pkt_fwd/*.json ~/lora/exec/
$ cd ~/lora/exec

I modified the gateway_ID for my gateway in ~/lora/exec/local_conf.json:

{
/* Put there parameters that are different for each gateway (eg. pointing one gateway to a test server while the others stay in production) */
/* Settings defined in global_conf will be overwritten by those in local_conf */
    "gateway_conf": {
        "gateway_ID": "AA555A0000000001" /* you must pick a unique 64b number for each gateway (represented by an hex string) */
    }
}

And finally, I started the packet forwarder:

lg@lora-gateway-mk1:~/lora/exec$ sudo ./basic_pkt_fwd
[sudo] password for lg:
*** Basic Packet Forwarder for Lora Gateway ***
Version: 2.1.0
*** Lora concentrator HAL library version info ***
Version: 3.1.0; Options: ftdi;
***
INFO: Little endian host
INFO: found global configuration file global_conf.json, parsing it
INFO: global_conf.json does contain a JSON object named SX1301_conf, parsing SX1301 parameters
INFO: lorawan_public 1, clksrc 0
INFO: Configuring TX LUT with 16 indexes
INFO: radio 0 enabled (type SX1257), center frequency 868200000, RSSI offset -166.000000, tx enabled 1
INFO: radio 1 enabled (type SX1257), center frequency 869200000, RSSI offset -166.000000, tx enabled 0
INFO: Lora multi-SF channel 0>  radio 0, IF -100000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 1>  radio 0, IF 100000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 2>  radio 0, IF 300000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 3>  radio 1, IF -350000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 4>  radio 1, IF -150000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 5>  radio 1, IF 325000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 6 disabled
INFO: Lora multi-SF channel 7 disabled
INFO: Lora std channel> radio 0, IF 100000 Hz, 250000 Hz bw, SF 7
INFO: FSK channel> radio 0, IF 100000 Hz, 125000 Hz bw, 50000 bps datarate
INFO: global_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
INFO: gateway MAC address is configured to AA555A0000000000
INFO: server hostname or IP address is configured to "127.0.0.1"
INFO: upstream port is configured to "1680"
INFO: downstream port is configured to "1680"
INFO: downstream keep-alive interval is configured to 10 seconds
INFO: statistics display interval is configured to 30 seconds
INFO: upstream PUSH_DATA time-out is configured to 100 ms
INFO: packets received with a valid CRC will be forwarded
INFO: packets received with a CRC error will NOT be forwarded
INFO: packets received with no CRC will NOT be forwarded
INFO: found local configuration file local_conf.json, parsing it
INFO: redefined parameters will overwrite global parameters
INFO: local_conf.json does not contain a JSON object named SX1301_conf
INFO: local_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
INFO: gateway MAC address is configured to AA555A0000000001
INFO: packets received with a valid CRC will be forwarded
INFO: packets received with a CRC error will NOT be forwarded
INFO: packets received with no CRC will NOT be forwarded
INFO: [main] concentrator started, packet can now be received

##### 2016-08-27 06:09:07 GMT #####
### [UPSTREAM] ###
# RF packets received by concentrator: 1
# CRC_OK: 0.00%, CRC_FAIL: 100.00%, NO_CRC: 0.00%
# RF packets forwarded: 0 (0 bytes)
# PUSH_DATA datagrams sent: 0 (0 bytes)
# PUSH_DATA acknowledged: 0.00%
### [DOWNSTREAM] ###
# PULL_DATA sent: 3 (0.00% acknowledged)
# PULL_RESP(onse) datagrams received: 0 (0 bytes)
# RF packets sent to concentrator: 0 (0 bytes)
# TX errors: 0
##### END #####

All seems to be working okay. Here is a photo of the MK1 LoRa gateway:

LoRa gateway MK1 - Raspberry Pi + Multitech LoRa mCard