Private Local LoRa Networks

LoRa has been getting a lot of attention lately: IBM, Cisco, and Espotel to name a few. She caught my eye early on, but I didn’t really like the idea of thousands of motes broadcasting messages through transparent ‘dumb’ gateways to a central server in the cloud before any useful actions could be taken on the data. If the server wanted to send down a response, it had to do so within the mote’s small receive window. The design doesn’t feel scalable, and I don’t want to pay for cellular data usage or compute cores just to throw the data away when it should have been dropped at the gateway. If the solution doesn’t have to be hooked into the Internet, a more closed system may be a simpler, safer, and more cost effective solution.

Enter Multi-Tech’s programmable gateway, the MultiConnect® Conduit™.

Conduit_Platform2

Multi-Tech Systems is one of the first companies to release a LoRa network gateway that allows the LoRa network to be managed … wait for it … at the gateway. I imagine there is some work to be done to make this compatible with Semtech’s LoRaWAN architecture, but since it is a programmable gateway, if you wanted to, you could just run the ‘dumb’ packet forwarder to transform it into a transparent gateway. An all or nothing approach is fine for a lot of situations.

This product allows developers to run custom rules and logic on the upstream data at the gateway to determine if immediate action should be taken, or if the data should just be dropped. Between its swappable hardware accessory cards, and its open development platform (mLinux), this LoRa gateway has everything it needs to provide a private, self-contained, Intranet of Things solution. On top of that, the software on their LoRa motes (end-points) are built using ARM’s mbed platform, making it very easy to provide custom logic on the RF module itself.

What is the point of an IoT ‘thing’ if it’s not on the Internet? I asked the same question about my cat memes. As much pressure as there is right now to put your ‘thing’ on the Internet, sometimes it’s better to:

Keep it secret!  Keep it safe!

Other times, you just want to be more cost effective. I hear vending machines have very low profit margins, and paying for cellular service at each unit or line of units is too expensive, and may not even be possible if cell reception is poor. LoRa has great penetrating power and low-cost end points in comparison to cellular modules. You won’t be sending video advertisement media over the air with this, but knowing when restocking or maintenance is needed could be worth the investment. There’s an article showing the range of indoor LoRa motes with an integrated antenna reaching a distance of 2.5 km.
http://embeddedexperience.blogspot.com/2015/05/lora-network-coverage_22.html

Anyway, I just got my LoRa Development Kit so I thought I would write a ‘hello world’ article. I will walk through the steps to get a private LoRa network up and running on Multi-Tech’s Conduit using a MTAC-LORA accessory card, a MultiConnect® LoRa mDot™ mote, and Multi-Tech’s UDK developer board. I plan on doing an article on developing custom images for the Conduit using Yocto, and one on building mbed apps locally for the mDot. The end goal of this is to help make the transition of power over to the machines as smooth as possible once they become self-aware. You’re going to want to be on the winning side. Alright, if you don’t have one already, grab a beer and lets get started.

Step 0: MultiConnect® Conduit™

The MultiConnect Conduit has two hardware accessory card slots that make hardware I/O configurable. Multi-Tech currently has a Multi-Function Serial card, a GPIO card, and a LoRa Gateway card, with WiFi/Bluetooth and Ethernet cards on their roadmap. This particular version of the Conduit also has a built-in cellular radio (Telit HE910).
http://www.multitech.net/developer/products/multiconnect-conduit-platform/

Plug in the LoRa Accessory Card (MTAC-LORA) and supply power to your Conduit (MTCDT).
The Conduit’s default address is 192.168.2.1.

Most of the time you’ll probably be interacting with the Conduit over Ethernet, but for the initial setup I found it easier to use the serial debug port for configuration.

Unscrew the front Multi-Tech logo and access the micro-USB serial debug port. Be very gentle with the micro-USB serial debug connector so it doesn’t accidentally break off.

MTCDT Serial Debug Port

Teraterm and putty work to access the Conduit on Windows; minicom, microcom, etc can be used on Linux. The baud rate should be 115200.

Access the Conduit using the default username and password (root:root).

Configure the LoRa Network parameters on the Conduit:
mkdir /var/config/lora
cp /opt/lora/lora-network-server.conf.sample /var/config/lora/lora-network-server.conf

Use vi to set your LoRa network name and passphrase in /var/config/lora/lora-network-server.conf:

	"network": {
		"public": false,            /* set to false for private LoRa network */
		"leasetime": 1440,          /* time until mDot join expires (minutes) */
		"name": "DisgruntledRats",  /* configure network security */
		"passphrase": "all.your.base.are.belong.to.us"
	}

Your network name has to be at least 8 characters long. Also, note your frequency sub-band as we will need to configure this the same on the mDot:

	"lora": {
		"frequencyBand": "915", /* US="915", EU="868" */
		"frequencySubBand": 7,  /* Sub-band for US operation, 1-8 */
		"maxTxPower": 14,       /* Max Tx power (dBm), -6 to 26 */
		"nodeQueueSize": 16,
		"nodeResetTime": 10,
		"nodeLostTime": 600,
		"frequencyEU": 867500000, /* center freq for extra EU channels (Hz) */
		"timeToPktFwd": 100
	}

To configure the Conduit’s IP address, edit the network interface configuration file on the device:
vi /etc/network/interface

After saving the configurations, run:
ifconfig eth0 down
ifconfig eth0 up

We’ll come back to this device a little later, but grab another beer and explore a bit before rebooting:

* Cellular Radio Information:
radio-query --static
radio-query --dynamic

* Turn an LED on and off
mts-io-sysfs store led-a 1
mts-io-sysfs store led-a 0

* Play some Russian Roulette
WARNING: The following command rolls a 1 in 6 chance to delete your entire file system. You’ve been warned.
[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo *Click*

Step 1: MultiConnect® mDot™

The MultiConnect® mDot™ LoRaWAN™ ready, low-power wide area network RF module is a neat little mote that is mbed compatible providing developers with the option to put brains on the mDot itself instead of just using it as a transport. I will put together an article on using ARM’s mbed site for mDot application development and how to pull the build system down for offline development, but you may be surprised at how easy it is, so in the mean time check it out yourself.
http://www.multitech.net/developer/products/multiconnect-mdot/
http://www.multitech.com/manuals/s000612.pdf
http://mbed.org/

Plug your mDot onto the UDK board and hook up to your PC via micro-USB and serial cable. There are no special drivers needed for this section, so if you are on Windows you can cancel any “searching for driver” installation pop-ups that may occur. If you want to setup the virtual USB COM port on Windows for debugging at this time, install STMicro’s ARM mbed serial port driver, but everything you really need happens on the serial port with the mDot’s default LoRa AT command app.
https://developer.mbed.org/teams/ST/wiki/ST-Link-Driver

mDot and UDK

You should be able to send AT commands over the serial port (buad 115200) using Teraterm and putty on Windows; minicom, microcom, etc can be used on Linux:
The results of the ATI command should display version 0.0.14, or a more recent version. If you have an older version the following link provides an easy guide to get caught up:
http://www.multitech.net/developer/software/mdot-software/mdot-firmware-upgrade/

The command AT&V will display the current settings.

Set the frequency sub-band, network name, and network passphrase to be the same as the configurations set on the Conduit in Step 0:
AT+FSB=<SUB-BAND>
AT+NI=1,<NETWORK_NAME>
AT+NK=1,<NETWORK_PASSPHRASE>

Check that the settings are correct
AT&V

Save and restart
AT&W
ATZ

You should see something similar to the following:

at+fsb=7

OK
at+ni=1,DisgruntledRats
Set Network Name: DisgruntledRats

OK
at+nk=1,all.your.base.are.belong.to.us
Set Network Passphrase: all.your.base.are.belong.to.us

OK
at&w

OK
atz

OK

After you have configured, saved, and reset the mote, attempt to join the network:

AT+JOIN

You should see an output like the following:

at+join
Successfully joined network

OK

On the Conduit, the /var/log/lora-network-server.log file should display something similar to the following:

18:40:28:849|INFO| Parsing 1 rx packets
18:40:28:856|INFO| Received join request
18:40:28:856|INFO| Queue join response 17 bytes
18:40:28:864|INFO| Send Join Accept - EUI: 00:80:00:00:00:00:9a:a8 ADDR: 00000001
18:40:28:865|INFO| Schedule TX Time on air: 100 ms
18:40:29:775|INFO| Frame transmitted to 00:00:00:01 via GW (00:80:00:00:00:00:9a:3c Chan LC6 127.0.0.1:58604) Seq# 0
18:40:29:780|INFO| Transmit message 186 bytes

If you are able to get your mote to join your LoRa network, good job! You’ve earned yourself another beer. If you did not, no more beer for you. Make sure your configurations for frequency sub-band, network name, and network pass-phrase are identical on both the Conduit and the mDot. You can also tail the /var/log/lora-network-server.log to watch what is happening as the mDot attempts to join. If there is not a /var/log/lora-network-server.log file, it may be that one of your configurations is not allowed causing the lora-network-server to exit. You may try executing the lora-network-server manually to see if runtime output provides any additional information:
/opt/lora/lora-network-server -c /var/config/lora/lora-network-server.conf

Step 2: hello

Send a message from the mDot to the Conduit:

AT+SEND=<MESSAGE>

On the mDot:

at+send=hello

OK

On the Conduit: /var/log/lora-network-server.log:

18:41:3:713|INFO| Parsing 1 rx packets
18:41:3:714|INFO| SeqNo: 00000001 PrevSeqNo: 00000000 Duplicate: no

18:41:3:715|INFO| Addr: 00:00:00:01 MIC Check: passed
18:41:3:726|INFO| Packet accepted from Node 00:00:00:01 GW 00:80:00:00:00:00:9a:3c (127.0.0.1) Seq# 1 ADR disabled SF9BW125
18:41:3:726|INFO| Schedule TX Time on air: 100 ms

The Conduit’s LoRa Network server uses mosquito, an internal MQTT message broker, to publish upstream messages and subscribe to downstream messages:
http://mosquitto.org/

On the Conduit, we can subscribe to all upstream LoRa messages with the following command:
mosquitto_sub -t lora/+/up

You should see something similar to the following when you send ‘hello’ up from the mote.

{"chan":2,"codr":"4/5","data":"aGVsbG8=","datr":"SF9BW125","freq":"912.3","lsnr":"11.8","modu":"LORA","rfch":0,"rssi":-10,"seqn":1,"size":8,"timestamp":"2015-07-03T18:40:28Z","tmst":3548047}

The ‘data’ element is base64. “aGVsbG8=” decodes to ‘hello’ in ASCII.

Step 3: world

Send a message down to the mDot from the Conduit:
You will need the mDot’s device ID found by issuing the command AT+DI to the mDot.

On the Conduit, use the following command to queue a downstream message:

mosquitto_pub -t lora/<MDOT_ID>/down -m '{ "data":"d29ybGQ=" }'

The ‘data’ element must be base64 encoded. Note that LoRa protocol states that downstream messages can only go out to the mDots at a specified interval from receiving an upstream message, i.e. the mDot always initiates communication, and only listens during a brief window after transmitting its message, so you may have to send another upstream message from the mote in order for the gateway to know when to send out the downstream message.

The received message on the mDot:

Packet data:
776f726c64

OK

The response on the mDot is in hexadecimal. 0x776F726C64 is ‘world’ in ASCII.

Congratulations!! By now you are either drunk and/or have successfully validated that all the equipment you purchased actually works. In future articles I will go over developing a custom image for the Conduit using Yocto, and write up an article on developing software for the mDot. Thanks for reading and if you have any questions, corrections, or memes, please leave them in the comments below.

No Comments Yet.

Add Your Comment

You must be logged in to post a comment.