Designers of Internet of Things (IoT) sensor and actuator networks for remote monitoring and control applications ranging from agriculture and mining to the smart city require a long-range wireless interface that is secure, robust, low maintenance, and relatively easy to deploy. A good option for such applications is LoRaWAN, with a range of up to 15 kilometers (km) across rural line-of-sight connections and up to 5 kilometers (km) in urban areas—using end-devices with batteries that can last up to 10 years.
While LoRaWAN is a mature low-power, wide-area network (LPWAN) technology, developers are always in need of ways to simplify deployment and connect to the cloud.
The challenge for engineers new to LoRaWAN IoT projects comes from dealing with the complexities of not only setting up the wireless end-device but also interfacing with the gateway and a cloud IoT platform. The task is made much easier with vendor starter kits that include all the elements needed to build and operate a prototype.
This article introduces LoRaWAN and explains how the technology complements short-range wireless sensor networks by forming an LPWAN to forward sensor data to the cloud. It then introduces and describes how to use Digi’s XON-9-L1-KIT-001 starter kit—which includes a multi-sensor end-device, a multi-channel gateway, and a device-to-cloud IoT platform—to design, develop and configure a LoRaWAN IoT solution based on an industrial platform.
What are LoRa and LoRaWAN?
LoRaWAN is an LPWAN technology for IoT devices characterized by a tens of kilometers range, low throughput (250 bits per second (bits/s) to 50 kilobits per second (Kbits/s) depending on the carrier frequency), and very low power consumption (for battery life up to a decade, depending on the application). Table 1 illustrates how LoRaWAN compares other IoT technologies.
Table 1: LoRaWAN is an LPWAN IoT wireless protocol with characteristics suited to low-throughput, long-range operation. The table shows how it compares with other wireless IoT technologies. (Image source: Semtech)
The LoRa specification defines the physical layer (PHY) and modulation technique underpinning LoRaWAN. The media access control (MAC) layer of the protocol stack is specified by the LoRaWAN standard (Figure 1).
Figure 1: LoRa physical layer (PHY) and modulation technique, and LoRaWAN MAC, plus the application layer, make up the LoRaWAN protocol stack. (Image source: Semtech)
Key to the technology’s range is the use of a modified form of direct sequence spread spectrum (DSSS) modulation. DSSS spreads the signal over a wider bandwidth than the original information’s bandwidth making it less susceptible to interference, boosting range. A downside of DSSS is that it requires a highly accurate (and expensive) reference clock. The LoRa Chirp Spread Spectrum (CSS) technique offers a low-cost and low-power DSSS alternative that eliminates the clock. CSS spreads the signal’s spectrum by generating a chirp signal that continuously varies in frequency (Figure 2).
Figure 2: The LoRa CSS technique spreads the signal’s spectrum by generating a chirp signal that continuously varies in frequency. The technique eliminates the need for the expensive reference clocks used in DSSS. (Image source: Semtech)
Using CSS, the timing and frequency offsets between the transmitter and receiver are equivalent, further reducing the complexity of the receiver design. LoRa modulation also includes a variable error correction scheme that improves the robustness of the transmitted signal, further boosting range. The result is a link budget transmit (Tx) power and receiver (Rx) sensitivity in decibel milliwatts (dBm) of around 154 dBm, enabling a single gateway or base station to cover entire cities.
In North America, LoRaWAN uses the 902 to 928 megahertz (MHz) Industrial, Scientific, and Medical (ISM) spectrum allocation. The wireless protocol defines 64 x 125 kilohertz (kHz) uplink channels from 902.3 to 914.9 MHz in 200 kHz increments. There are an additional eight 500 kHz uplink channels in 1.6 MHz increments from 903 MHz to 914.9 MHz. The eight downlink channels are 500 kHz wide, starting from 923.3 MHz to 927.5 MHz. The maximum TX power in North America is 30 dBm, but for most applications 20 dBm TX power is sufficient. Under U.S. FCC regulations there are no duty-cycle limitations, but there is a 400 millisecond (ms) max dwell time per channel.
Mesh networking is a technique for increasing range by forwarding messages between nodes to reach the edges of the network, but it does add complexity, reduces capacity, and decreases battery lifetime. Instead of using mesh networking, LoRaWAN employs a star topology whereby each (long-range) node connects directly with a gateway. Nodes are not associated with a specific gateway. Instead, data transmitted by a node is typically received by multiple gateways. Each gateway then forwards the received packet from the end node to the cloud-based network server via some form of backhaul (typically cellular, Ethernet, satellite, or Wi-Fi) (Figure 3).
Figure 3: LoRaWAN employs a star topology whereby each end device connects directly with one or more gateways. Each gateway then forwards the information to the cloud-based network server via a backhaul connection. (Image source: Semtech)
To make a long-range star network viable, the gateway must be able to receive messages from a high number of nodes. LoRaWAN achieves this high capacity by employing an adaptive data rate and using gateways that can receive simultaneous messages on multiple channels. A single eight-channel gateway can support a few hundred thousand messages per day. Assuming each end device sends ten messages a day, such a gateway can support about 10,000 devices. If more capacity is required, additional gateways can be added to the network.
LPWAN starter kit for rapid prototyping
LPWAN technologies are complex and can be a challenge for the inexperienced engineer. Not only does the developer have to set up the wireless end-device with a secure and robust connection, but also interface it with the gateway, provision it as part of the network, and then make the connection to a cloud IoT platform.
This buildout of an end-to-end LoRaWAN IoT solution is made simpler using a bespoke starter kit, such as Digi’s XON-9-L1-KIT-001 LoRaWAN Starter Kit (Figure 4). With such a starter kit, an engineer can quickly familiarize themselves with each step in the process, safe in the knowledge that the next stage can then quickly be incorporated. As a result, a non-expert can rapidly prototype a complete LoRaWAN IoT solution.
Figure 4: The XON-9-L1-KIT-001 LoRaWAN starter kit includes everything needed to prototype a network connection, including the HXG3000 Ethernet gateway, uplink and downlink, a Client Shield board, antenna, power supply, and a programming interface. (Image source: Digi)
LoRa features device classes that trade off network downlink communication latency against battery lifetime; the Digi starter kit provides support for LoRaWAN Class A (lowest power, bidirectional end devices), and Class C (lowest latency, end device receiver always on, bidirectional end devices).
The starter kit provides everything needed to set up a LoRaWAN prototype quickly and securely. Specifically, it includes an uplink/downlink, an expansion board or “Client Shield” with a LoRaWAN module, an LED, a digital input, temperature sensors, a Digi 8-channel LoRaWAN HXG3000 Ethernet gateway, an embedded developer application programming interface (API), and a 30-day free trial account for a device-to-cloud platform with scan-and-go mobile provisioning.
The HXG3000 gateway delivers long-range, non-line-of-sight, two-way communications over LoRaWAN, and can deal with up to 1.5 million messages per day. The product includes a 1.7 dBm omnidirectional radio, up to 27 dBm Tx power and -138 dBm Rx sensitivity. Operation is in the license-free U.S. 902 to 928 MHz band. The device is powered from either an AC supply or Power-over-Ethernet (PoE). Ethernet and LTE Cat M1 backhaul models are available.
The Digi LoRaWAN Client Shield is the part of the starter kit that supports engineers looking to prototype and develop LoRaWAN sensors. It provides connectivity to select compatible STMicroelectronics’ Nucleo (for example the NUCLEO-L053R8) and Arduino ARM Keil® Cortex®-M class microcontroller development boards for LoRaWAN client-side connectivity. In addition to Arduino stackable connectors, the Client Shield features a low-power thermistor temperature sensor, digital input slide switch, and a digitally controlled red, green, blue (RGB) LED. The shield has a U.FL connector and the associated antenna is included as part of the kit. The shield also incorporates the LoRaWAN module which operates in the license-free U.S. 902 to 928 MHz band. TX power is 14 to 20 dBm (Figure 5).
Figure 5: The XON-9-L1-KIT-001 Client Shield, housing the LoRaWAN module, can be mounted on an STMicroelectronics Nucleo (shown here) or Arduino development board. (Image source: Digi)
Digi X-ON is a complete device-to-cloud platform for IoT end devices. The platform provides both a development and an operational cloud solution. X-ON incorporates an integrated LoRaWAN network server and joins the server to support devices and gateways running the LoRaWAN wireless protocol. The join server handles join flow, including network and application server authentication and session key generation.
The platform enables the developer to:
- Configure, monitor, and diagnose devices or gateways from the web and mobile interface
- Automate deployment of devices and gateways with the provisioning app
- Manage wireless network gateways
- Collect and analyze data directly from end devices
- Use an inter-cloud API for real-time, two-way device data between multiple cloud platforms
- Log and trace real-time data messages for interactive operations and troubleshooting with end devices and gateways
- Integrate data through open APIs to develop more complex applications with third-party utilities (Figure 6)
Figure 6: The Digi X-ON is a device-to-cloud platform for IoT end devices that allows the developer to automate deployment of devices and gateways with the provisioning smartphone app. The developer can then configure, monitor, and diagnose devices or gateways from the web and mobile interface. (Image source: Digi)
Getting started on a LoRaWAN project
Because the Client Shield, STMicroelectronics Nucleo, and Arduino development boards use embedded ARM Keil microcontrollers and so are “ARM Keil Mbed enabled,” getting started on a project with the Digi starter kit is relatively straightforward. (ARM Keil Mbed is a platform and operating system (OS) for IoT devices based on 32-bit ARM Keil Cortex M-class microcontrollers.) The Client Shield includes an embedded AT command language and a simplified ARM Keil Mbed C++ Embedded API which is designed to abstract away the design complexities, simplifying development.
The Digi LoRaWAN Starter Kit’s Mbed compatibility enables application development work using ARM Keil’s Mbed online resources. The resources comprise three options. The Mbed Online Compiler allows the developer to instantly start application development without installing anything. All that’s needed is an Mbed account.
For more advanced application development, the Digi LoRaWAN Starter Kit can be connected to Mbed Studio, a desktop integrated development environment (IDE) for creating, compiling, and debugging Mbed programs. Finally, there’s the Mbed CLI, a command line tool which can be integrated into the developer’s preferred IDE.
The fastest route to development is to first set up the Digi X-ON account. Next, the developer needs to sign-up for an Mbed Online Compiler account. Then, after mounting the Client Shield on the development board, the assembly needs to be connected to a desktop computer using a USB cable. The “PWR” LED on the Client Shield and the “COM” LED on the development board will then illuminate indicating that the electronics are powered up.
The Mbed Online Compiler then guides the developer through a set of simple steps to add the hardware platform to the compiler. Once the hardware is added, code can be imported into the compiler from the examples of sensor applications in the Mbed repository (or other libraries) and downloaded into the development board. The compiler can also be used to change the LoRaWAN configurations such as the device class and network joining mode (Figure 7).
Figure 7: It’s simple to change the LoRaWAN configurations such as device class and network joining mode using the ARM Keil Mbed Online Compiler. (Image source: Digi)
Provided the gateway is running, the Client Shield/development board will join the network and start sending uplinks every 15 s (in default mode). On the X-ON account page, once the “Stream” button is pressed, data transmitted from the device will display on the screen.
For designers of IoT sensing and actuator networks, LoRaWAN offers license-free RF access, tens of kilometers range, low power consumption, good security and scalability, and robust connectivity. However, like many IoT wireless protocols, it can be challenging to deal with end-device connectivity, provisioning, gateways, and the streaming of sensor data to the cloud.
As shown, the Digi LoRaWAN Starter Kit addresses many of these issues. It features a Client Shield with a simplified ARM Keil Mbed C++ Embedded API, a LoRaWAN gateway with Ethernet backhaul, and an X-ON device-to-cloud platform with scan-and-go mobile provisioning. Using the starter kit, the developer can quickly get up and running with a LoRaWAN hardware prototype, develop and port sensor and actuator application code, and analyze and present data using the cloud platform.