Getting started with LoRa(WAN)

Tags: Embedded, Network, Wireless

It seems that LoRa(WAN) in general tends to be quite a source of confusion for those starting out with this technology. For starters, there is the difference between LoRa and LoRaWAN that are absolutely fundamental but often these terms are used interchangeably. In addition, there are many different starter kits and devices out there that are not necessarily compatible with each other. The need to build up a gateway network alongside building actual communicating devices doesn’t really help to make this all straight forward. Hopefully this text can help clear some of the confusion and get people to build both infrastructure and things (pun intended) on top of this promising network technology.

To WAN or not to WAN

Let me start by stating that most of the time, you’ll want the WAN part – but what is it really? Let’s start by looking at what LoRa without the WAN part is. LoRa represents the physical layer in the OSI model. In other words, it can be compared to 802.11 in a wireless LAN network, or even Ethernet in a typical LAN. LoRa itself is a proprietary technology based on chirp spread spectrum modulation and other techniques to achieve long range communication with limited bandwidth. All patents and IP are owned by Semtech.

While you could use LoRa as-is to send data, you will be limited in the number of communicating devices, and only achieve limited, if any, interoperability. This is where the WAN part comes in: LoRaWAN defines the MAC communication protocol and architecture (with three separate classes for different devices), standardised by the LoRa Alliance. This standard can be compared to higher level layers of the OSI model, and provides a framework to have multiple devices send data within the same frequency band without tripping over one another. It also provides the means of different devices from multiple vendors to interoperate, just like wireless LAN network cards and access points can coexist and talk to one another.

However, LoRaWan does not say anything beyond layer 3 (data link and network) of the OSI model. Typically, applications are built directly on top of the MAC. Libraries are available for a wide variety of platforms to make this less painful (some say even fun!).

 

Infrastructure

Suppose you build a LoRaWAN device like a temperature sensor. There are various examples on the net that will tell you how to do that with e.g. an Arduino or STM32 development kit, but it essentially comes down to picking an off the shelf LoRaWAN module (e.g. from Microchip) or shield (make sure you pick the right frequency for your region!), hooking it up to the Arduino or R-Pi, download some libraries and sample code – and presto. Yes, these will not be the cheapest possible options, but they get you up and running fast and allow you to focus on the application and not the hardware design. Personal recommendation: B-L072Z-LRWAN1 from ST Micro.

So now you have a device that sends out data to… where exactly? The amount of publicly available LoRaWAN infrastructure is still fairly limited. Even the access points deployed by The Things Network are fairly spread out and unless you’re lucky to live in one of the higher density areas (see: The Netherlands), chances are that your only option is to deploy your own. Having an access point of your own allows you to use it for your own purposes only, or you could tie it in with a larger network (like the one from The Things Network) and thus share your infrastructure with a wider audience.

There are several ways to get an access point going. Besides the hardware aspects, there is quite some software required as well, so building an access point might take some time. Even using some off the shelf components and following tutorials will not necessarily guarantee you’re up and running over a weekend. Alternatively, you can buy a gateway off-the-shelf. Prices will vary, but if you have limited time, this might be the way to go.

Probably the best DIY gateway tutorial available at this time is this one:

https://www.rs-online.com/designspark/building-a-raspberry-pi-powered-lorawan-gateway

Yes, based on an R-Pi like others, but at least this one results in a true LoRaWAN gateway (there are several LoRa only ones online that you want to avoid), and this one in particular uses a proper concentrator with multiple transceivers and a baseband processor. What this means in short is that you can handle multiple devices sending data at once. Keep an eye on the frequencies: the iC880A concentrator used in that tutorial operates in the 868MHz band, which is Europe. Your devices should therefore also operate in the same band. Europe can also use the 433MHz band (less used), while the USA uses the 915MHz band.

If you want to use an off the shelf gateway, you’re probably best off buying one from The Things Network. At 300Euro excluding VAT it’s pretty good value for money, and will get you up and running the fastest. You’ll also help expand the global network they are trying to build.

Once you have the gateway and your device talking to it, you need a packet forwarder to send the data to a server to do something useful with it. If you buy an off the shelf gateway from The Things Network, you’ll be able to use their API to pull in your data. In other words, the gateway contains the packet forwarder and makes this all pretty straightforward – just connect the gateway to the wireless/wired network. If you build your own, you can also hook it up to The Things Network (as described in that tutorial I mentioned before), or you can build up your own infrastructure. There is a nice software repository and instructions here:

https://github.com/Lora-net

This is from the same people that make the iC880A concentrator used in the tutorial above, and contains some pretty good documentation. You can deviate from the tutorial and build up your own server infrastructure if you don’t want to be hooked up to The Things Network infrastructure.

 

Have fun!