Post Category →Hands On

One of the most versatile LoRa / LoRaWAN gateways on todays market is Multitech Conduit with LoRa module. This nice blue boxes comes in 2 flavours; mLinux with everything driven from the command line and standard config files and the AEP version with a web based UI. The AEP version is intended for private LoRaWan deployments and where quick and easy configuration is required. I am not going to discuss benefits of Multitech gateway, there is another post coming where I will compare gateways from several vendors one of them being Multitech.

AEP lorawan

I will focus now on how to configure your AEP box to talk to TTN with PolyPacket Forwarder.

To begin, you need to install the Poly Packet Forwarder on your box. I suggest to download the package to another system and then use scp to move it to your Conduit:

Keep in mind, that this example is for SubBand 7 of North American flavour of Lora.
The local_conf.json will overwrite respective portion go global_conf.json with your site specific information

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": {
/* you must pick a unique 64b number for each gateway (represented by an hex string) */
"gateway_ID": "008000000000XXXX",
/* Email of gateway operator, max 40 chars*/
"contact_email": "YOUR_CONTACT_EMAIL",
/* Public description of this device, max 64 chars */
"description": "DESCRIPTION_OF_YOUR_GATEWAY",
/* Enter VALID GPS coordinates below before enabling fake GPS */
"fake_gps": true,
"ref_latitude": YOUR_GPS_LAT,
"ref_longitude": YOUR_GPS_LON,
"ref_altitude": YOUR_GPS_ALT
}
}

There is one more thing, since the UI controls switching between Packet forwarder mode and Network server mode, you will have no logging for the packet forwarder. In order to enable it, you need to issue the following command from your console:curl 127.0.0.1/api/loraNetwork -X PUT -d '{"log":{"syslog":false}}' -H "Content-Type: application/json"

At this point you can restart you lora service /etc/init.d/lora-network-server restart and your log should confirm that everything is in order:tail -f /var/log/lora-pkt-fwd-1.log
# Invalid gps time reference (age: 1464959181 sec)
# Manual GPS coordinates: latitude ....., longitude ...., altitude 111 m
##### END #####
INFO: [down] for server router.us.thethings.network PULL_ACK received in 106 ms
INFO: [up] PUSH_ACK for server router.us.thethings.network received in 108 ms
INFO: [up] PUSH_ACK for server ott1.iothub.ca received in 35 ms
INFO: [down] for server 127.0.0.1 PULL_ACK received in 1 ms
INFO: [down] for server ott1.iothub.ca PULL_ACK received in 34 ms
INFO: [down] for server router.us.thethings.network PULL_ACK received in 105 ms
INFO: [down] for server 127.0.0.1 PULL_ACK received in 1 ms
INFO: [down] for server ott1.iothub.ca PULL_ACK received in 34 ms
As you can see, we are also connecting to the localhost, so Conduit’s network server. I used that for some tests and find it very helpful.

At this point you can start your node-red (on the Conduit) and configure it to connect to TTN to retrieve and process your packets:

ttn

node-red & lorawan

From the node-red, processed packets are send to InfluxDB and then Grafana provides nice user interface:

SenseInAir over lorawan

Please let me know if you are interested in any write-ups on Node-Red and TTN (or other LoRaWan networks), but for now enjoy your AEP Conduit communicating flawlessly with The Things Network and LoRaWan.

During the last LoRa Alliance meeting in Rotterdam we discovered a new LoRa modules made by Shenzhen (China) based company, Dapu Telecom.

There are 4 options available, 2 radio only modules based on SX1272 and SX1276 Semtech chips and two complete modules with MCUs also based on SX1272 and SX1276 called respectively RM7201 and RM7601.

For this exercise, we obtained radios with MCUs. One important note, there is no specific part number for EU, Asia or North America. According to Dapu, the software stack will set the radio into the respective ISM band for your region. This requires further investigation, as small hardware changes between EU and North America (RF part) are present in Semtech’s reference designs.

Here is the RM7601 with MCU and SX1276 radio chip

This is theRM7201 with MCU and SX1272 radio chip

Both of them use the same MCU – STM32L151C8U6, only the radio is different as mentioned above.

If you go to the official Semtech git repository and look at their demo code, you will find out that Semtech uses the STM32L151 MCU series as well, just using a different variant of this MCU. This will most likely allow us to port the Semtech LoraWan stack to DAPU hardware with minimal effort.

Store the source code onto your local hard drive, let’s say C:\LORA\and unzip it, then go to C:\LORA\LoRaMac-node-master\Keil\SensorNode\LoRaMac\classA, use Keil5 (i used Keil5.17 lasted one) to open the project. Why “SensorNode” demo code? because that code uses the same MCU as one used in RM7601 module.

As Semtech used Keil4 to create the LoRaWAN demo code, Keil will first migrate the project to Keil5 when you first open it, just allow it do to so.

In the RM7601 data sheet for the SX1276 radio chip we see the following pin definitions:

following this table, we can quickly change the Semtech source code and update pin definitions in C:\LORA\LoRaMac-node-master\src\boards\SensorNode\board.h to the following pins as follows:

Compile the code and flash it to the RM7601, then login via ssh into your gateway and watch for our updated module to join the gateway. For help on how to set up the Multi-tech gateway, please follow our blog posts:

As with RM7601, I expected simply changes in the config files, but unfortunately, it was not that easy . At the beginning, I’ve tried to use the same project – NodeSensor, but I quickly found out that I would have to port the SX1272 driver as this project does not include support for the SX1272. Porting the SX1272 driver should be easy as most likely it would involve just changing some header definitions. However, after looking deeper into Semtech code, I found another project which does have support for the SX1272, the Loramote project.

As the RM7201 uses a smaller header, my connector would not fit, so i soldered 4 wires (SWCLK, SWIO, VDD and GND) to the RM7201 module directly:

Once installed, try compiling one of the demo programs for Teensy, just to make sure that everything went ok.

Now, we are ready to proceed with actual LoRaMac code. First, Clone the whole package to your system, then add it as new library to your Arduino SDK.

You are almost done ;), just few modifications left…

I will be using defaults with the exception of the DevAddr below.

In the main file, we need to change DevAddr to something unique globally.

static const u4_t DEVADDR = 0x03FF0001 ;

//In this example I used 0x03FFEBB2, you will see it below in the section when we define node manually in gateway's db.

This is equivalent of MAC address associated with your Ethernet port. In production, you will have your own prefix, obtained from IEEE, but for now we can just use anything, as long as it’s not duplicated on your network.

Then, we will adjust Spreading Factor from 11 to 9 to match gateway configuration (as per FCC in North America, Spreading Factor could be between 7 and 10).// Set data rate and transmit power (note: txpow seems to be ignored by the library)
LMIC_setDrTxpow(DR_SF9,14);

Now, you need to use your favoured editor to change the config.h located under arduino libraries (in case of MacOS: /Users/<Your User Name>/Documents/Arduino/libraries/arduino-lmic-v1.5-master/src/lmic to support 915MHz as North American ISM frequency and SX1276 chip for RFM95 HopeRF radio module.#ifndef _lmic_config_h_
#define _lmic_config_h_

// In the original LMIC code, these config values were defined on the
// gcc commandline. Since Arduino does not allow easily modifying the
// compiler commandline, use this file instead. (MK)

Depending if you run gateway or packet forwarder, go to you logs or run mosquitto_sub -t lora/+/up to see incoming packets.

As soon as you run your demo code, you should see something like that:{"chan":7,"cls":0,"codr":"4/5","data":"d29ybGQ=","datr":"SF9BW125","freq":"913.3","lsnr":"-12.8","modu":"LORA","rfch":1,"rssi":-113,"seqn":5,"size":8,"timestamp":"2015-11-18T16:08:51Z","tmst":2397020652}

where “d29ybGQ=” is base64 representation of the word “hi”.

Almost forgot about last cosmetic modification… in order to avoid an extra character at the end of the string, modify// Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, mydata, sizeof(mydata), 0);
to // Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, mydata, sizeof(my data)-1, 0);

Enjoy and stay tuned…

Soon, I will share my experience with modules from one of the new LoRa node makers from China.

I will also experiment with LoRa range, explaining ways to get the most from your node…