Quantcast
Channel: 懒得折腾
Viewing all articles
Browse latest Browse all 764

LoRaWAN Part 1: How to Get 15 km Wireless and 10-Year Battery Life for IoT

$
0
0

LoRaWAN Part 1: How to Get 15 km Wireless and 10-Year Battery Life for IoT

Contributed By Digi-Key’s North American Editors

Editor’s note: In Part 1 of this two-part series, we will discuss the issue of long-range, low-power communication for IoT and how to achieve it, securely. In Part 2, LoRaWAN Part 2: How to Use Microchip’s Modules to Speed IoT Design, we will discuss an implementation using off-the-shelf LoRaWAN hardware and software.

Low-power wireless networks are a key enabler for the Internet of Things (IoT), but familiar options such as Bluetooth, ZigBee, Wi-Fi, or cellular, lack an acceptable combination of extended range and battery life. To address this, new sub-GHz specifications are being offered, one of which is LoRaWAN.

LoRaWAN can achieve a 15 km range at power consumption levels low enough to enable 10-year battery life. Further, the availability of an off-the-shelf development kit lets designers quickly bring up a complete LoRaWAN network application with minimal effort.

This article will look at the advantages of sub-GHz communication, examine the important role of modulation schemes, and introduce LoRaWAN with a description of its physical and media access control layers, as well as its security features. It will conclude with a brief introduction to the RN2903 LoRaWAN module from Microchip Technology.

Sub-GHz advantages

High-frequency connectivity options provide high data rates but have limited range at acceptable power levels. For power-constrained designs that need extended range, low-frequency operation is a preferred approach. The lower the frequency, the less power is required to maintain a particular link budget at a specified range, as shown by the Friis transmission equation:

Equation 1

Where:

Pt = transmitted power

Pr = received power

Gt = transmitter antenna gain

Gr = receiver antenna gain

λ = wavelength

d = distance between transmitter and receiver

Lower frequency transmissions typically translate to lower data rates, but IoT applications rarely present significant throughput requirements. Additionally, lower data rates bring another advantage in the form of reduced error rates, thereby decreasing the sensitivity requirements of the receiver.

The downside is that with slow links the duty-cycle increases, thereby increasing the chance of error due to interference from noise and other signals. Further, the longer the time required to transmit a message means increased power consumption at both the transmitter and receiver ends.

That said, sub-GHz communications can help meet the requirements for range, power, and data rate required by most IoT applications. Still, the choice of modulation method used for data encoding adds a further layer affecting these three key parameters.

Modulation methods

Communications specialists have for years relied on spread spectrum modulation techniques to enhance immunity to noise or interfering signals. Channel coding methods used in spread spectrum techniques, such as direct-sequence spread spectrum (DSSS), are able to reduce transmitter power requirements by building redundancy into the spreading algorithm.

Although this approach can support very high data rates, it requires a high bandwidth carrier and sophisticated modulation/demodulation signal chains able to ensure efficient transmission and reception of the wideband signal. IoT applications rarely need the kind of maximum data rates possible with modulation techniques such as DSSS. Further, the design complexity and power requirements associated with traditional spread spectrum techniques can make them less effective for low-cost, battery-operated IoT designs.

This is where LoRa comes in. Developed by Semtech, LoRa is a unique spread spectrum modulation method that brings some of the benefits of spread spectrum noise immunity, while simplifying design requirements. LoRa modulation is based on a frequency modulated “chirp” signal that can be generated with a relatively simple fractional-N phase-locked loop (PLL).

When initiating a LoRa transmission, a LoRa modem issues a preamble comprised of a series of chirps (Figure 1, left). The transmission continues with a series of chirps that encode data essentially as frequency jumps in the chirp signal, similar to the use of multiple frequency tones to encode data in M-ary FSK (Figure 1, right).

Image of waterfall view showing the repeated chirps

Figure 1: This waterfall view (newest data at the top) shows the repeated chirps used in the LoRa transmission preamble (left) and the chirps encoding the payload of a transmission (right). (Image source: Link Labs)

On the receiver side, a PLL can lock onto the preamble to initiate reception of a message stream. Because of the distinct pattern of the chirps, a LoRa modem can detect signals as low as 20 dB below the noise floor. LoRa technology enables -148 dBm sensitivity, enabling robust connectivity over very long ranges. Further, a LoRa modem can receive several different transmissions simultaneously, each differing only in chirp rates. As a result, it can support very large numbers of IoT devices operating simultaneously.

LoRa networking

LoRa technology’s unique modulation method lies at the heart of performance characteristics that make it well suited to IoT applications: It can operate successfully at ranges exceeding 15 km in suburban settings and more than 2 km in dense urban environments. It can achieve over 10-year battery life and it can operate in networks comprising up to 1 million nodes. Further, its support for different chirp rates, or “spreading factors,” gives designers the flexibility to trade data rate for range or power as needed to optimize network performance (Figure 2).

Diagram of LoRa technology for IoT developers

Figure 2: With LoRa technology, IoT developers can trade data range for bit rate by using different spreading factors. (Image source: Microchip Technology)

For all its benefits, LoRa is still a physical layer (PHY) mechanism. In an actual IoT application, developers’ ability to apply it as a connectivity solution depends on the availability of a network protocol stack able to build on the LoRa PHY. The LoRaWAN standard does just that with its definition of the media access control (MAC) layer designed to operate with the LoRa PHY. Created and maintained by the LoRa Alliance, the LoRaWAN specification was developed specifically for long-range IoT applications and provides access and control protocols geared for secure, low-power wireless communications.

LoRaWAN defines a familiar IoT hierarchy comprising end devices, local controllers, and cloud-based servers (Figure 3). In LoRaWAN terminology, end devices are connected wirelessly in a star topology to a gateway, and gateways connect through IP networks to a central network server. The network server can double as an IoT application server or connect to one or more separate application servers.

Image of LoRaWAN network topology

Figure 3: The LoRaWAN network topology presents a familiar IoT hierarchy comprising end devices connected wirelessly (dotted lines) to gateways that connect through IP networks (solid lines) to an upstream network server and application servers. (Diagram drawn using Digi-Key Scheme-it)

https://www.digikey.com/schemeit/embed/lorawan-application-PLVM35O2011G/

The LoRaWAN stack provides applications with a standard interface to LoRa-based communications (Figure 4). At the bottom of the stack, the LoRa PHY works with regional sub-GHz ISM bandwidth allocations. Above the LoRa PHY, the LoRaWAN MAC provides familiar MAC-layer services including channel access and addressing. As described below, the LoRaWAN standard defines specific message formats and timing for uplink and downlink transactions.

Image of LoRaWAN media access control (MAC)

Figure 4: Built on the LoRa PHY, the LoRaWAN media access control (MAC) defines the message formats for different device classes. (Image source: LoRa Alliance)

Communications options

The LoRaWAN MAC protocol is designed to support IoT applications with different requirements for downlink communications from a LoRaWAN gateway to an end device. As defined by the LoRa Alliance, the LoRaWAN MAC includes three different classes of devices, all of which support bidirectional communications but differ in their downlink availability:

  • Class A operation supports low-power devices such as wireless sensor nodes that require minimal downlink communication from the server after uplink transmission. A Class A device can transmit data to a gateway any time, but can only receive within two windows, each occurring at a specified delay after the transmission (Figure 5).

Diagram of default Class A transaction

Figure 5: In the default Class A transaction, a device transmits a LoRa-compatible message to a gateway and then listens after preset delays for a response in two receive windows. (Image source: LoRa Alliance)

  • Class B operation extends Class A with additional downlink receive windows. Besides the usual two short receive windows following transmission, a Class B IoT device listens for additional downlink messages at other scheduled windows. The downlink windows occur at specific times following a beacon that is transmitted by a recognized LoRaWAN gateway. Class B downlink scheduling provides a mechanism for applications to contact the IoT device at specific times rather than depending on the non-deterministic downlink windows available in default Class A operation.
  • Class C operations supports devices that need near-continuous availability of downlink receive windows. A Class C device constantly listens for downlink messages except when it is transmitting data or opening the two default receive windows.

LoRaWAN is designed with multiple security features, using a combination of device, session and application crypto keys to encrypt data and to authenticate device access to the network. For a LoRaWAN application, end devices can be programmed at the factory with the authentication information required to join a specific LoRaWAN network, which LoRaWAN calls “activation by personalization”. LoRaWAN also offers “over-the-air activation”, which specifies a procedure for authentication and authorization required for a device to join any available LoRaWAN network.

For network-join operations and secure data communications, only IoT devices and the application server hold crypto secrets (Figure 6). Encrypted messages are simply conveyed, not processed, by the intermediate gateway and network, eliminating their use as an effective attack surface for bad actors.

Image of crypto keys are maintained only in end devices and application servers

Figure 6: In a typical LoRaWAN application, crypto keys are maintained only in end devices and application servers (green highlight). The end-device MCU and upstream IoT application software (red highlight) operate on plain text, while the LoRaWAN gateway and network server (blue highlight) see only encrypted data. (Image source: Microchip Technology)

Simplified communications

Designed to simplify development of LoRaWAN communications, Microchip Technology offers a discrete module that implements LoRa modulation and provides LoRaWAN compatibility. The Microchip RN2903 supports LoRaWAN-compatible communications at the ITU Region 1 ISM standard frequency band of 915 MHz. Along with LoRa modulation, the onboard transceiver also supports FSK and GFSK modulation for proprietary network-protocol design. Similarly, Microchip’s RN2483 provides identical features, supporting the ITU Region 2 ISM bands at 433 or 868 MHz.

Diagram of Microchip LoRa module

Figure 7: The Microchip LoRa module provides a drop-in solution for LoRaWAN connectivity with its onboard command processor, LoRaWAN protocol stack, radio transceiver, and serial connectivity. (Image source: Microchip Technology)

Fully certified, the Microchip module includes all the components required to implement LoRaWAN connectivity (Figure 7). The module’s command processor uses the onboard LoRaWAN firmware to fully support the LoRaWAN Class A protocol. The onboard EEPROM provides storage for LoRaWAN configuration parameters, enhancing performance and increasing security by reducing data transfers between the host and module.

Conclusion

In creating IoT devices intended for long-range communications, developers face a challenge in finding a wireless connectivity able to meet requirements for extended range, long battery life, and sufficient data rate. LoRaWAN can satisfy these demands with unique modulation technology that can achieve a 15 km wireless range and a 10-year battery life. Still, meeting LoRaWAN’s underlying PHY and MAC requirements can stretch development resources and project schedules. Microchip Technology’s RN2903 LoRa module provides a near drop-in solution for implementing LoRaWAN in IoT device designs. As we will discuss in part two, end-device connectivity is only part of a complete LoRaWAN-based IoT application.

In Part 2 of this two-part series, we will discuss how to implement the Microchip RN2903 module using relevant code examples. We will also examine its role in a Microchip LoRaWAN evaluation kit that offers a complete off-the-shelf LoRaWAN-compatible solution including hardware and software for end devices, gateways, and network servers.

LoRaWAN Part 2: How to Use Microchip’s Modules to Speed IoT Design

Contributed By Digi-Key’s North American Editors

Editors Note: In Part 1 of this two-part series, LoRaWAN Part 1: How to Get 15 km Wireless and 10-Year Battery Life for IoT, we looked at the ability of LoRaWAN to meet the need for long-range, low-power IoT communications. Here in Part 2, we will show how developers can use an off-the-shelf kit based on the Microchip Technology RN2903 to implement a LoRaWAN IoT application.

LoRaWAN offers performance characteristics well matched to the needs of the IoT. Besides its extended operating range and low power requirements, LoRaWAN provides secure, flexible communications options. Yet, the hardware and software required to implement a LoRaWAN solution can prove a major obstacle to development teams focused on the IoT application itself.

This article will elaborate on Microchip Technology’s RN2903 LoRa module introduced in Part 1, and show how to use it with some additional hardware and software to realize a long-range, low-power IoT design.

Quick-start kits

Microchip Technology’s RN2903 LoRa module is a near drop-in LoRaWAN hardware solution for an IoT design. Even so, it remains only the cornerstone of a complete LoRaWAN network, and developers must still account for support hardware and software systems. Microchip addresses this need with a comprehensive evaluation kit that provides the additional elements needed to implement LoRaWAN for the IoT.

As mentioned in Part 1, Microchip Technology’s RN2903 supports LoRaWAN-compatible communications at 915 MHz and is designed to simplify development of IoT applications. Fully certified, the Microchip module includes all of the components required to implement LoRaWAN connectivity (Figure 1). The module’s command processor uses the onboard LoRaWAN firmware to fully support the LoRaWAN Class A protocol. The onboard EEPROM provides storage for LoRaWAN configuration parameters, enhancing performance and increasing security by reducing data transfers between the host and module.

Diagram of Microchip’s LoRa module for LoRaWAN connectivity

Figure 1: Microchip’s LoRa module provides a drop-in solution for LoRaWAN connectivity with its onboard command processor, LoRaWAN protocol stack, radio transceiver, and serial connectivity. (Image source: Microchip Technology)

The Microchip RN2903 module provides a dedicated UART interface for communications with an external MCU host. In addition, the module includes 14 GPIO pins that developers can program using module firmware to monitor or control external devices such as switches and LEDs. Finally, the module provides an RF signal pin for easy connection to a simple sleeve dipole antenna.

The module’s command processor performs LoRaWAN transactions according to commands received through its UART interface from an external host MCU. As with any network communications method, LoRaWAN messages are sent and received in specific formats. For LoRaWAN, the LoRa Alliance standard specifies these formats in exacting detail at the byte level. The RN2903 module provides an intuitive text-based approach that abstracts LoRaWAN standard byte-level formats to a set of keyword commands with optional parameters.

Microchip defines three types of keywords:

  1. mac commands for LoRaWAN MAC configuration and control
  2. radio commands targeting the PHY radio layer
  3. sys commands for additional module functions such as providing module firmware version information or accessing the module’s EEPROM store

For example:

mac tx uncnf 30 23A5

sends a message on port 30 with data value “23A5”. The “uncnf” option indicates that the device is not requesting confirmation from the network server. Alternatively, use of the “cnf” option indicates that the device expects the network server to acknowledge receipt. The LoRa module is responsible for encrypting this message before transmitting it to its gateway for delivery to the network server.

radio tx 6d657373616765

transmits a package containing the values [0x6d][0x65][0x73][0x73][0x61][0x67][0x65] (the sample text string “message” in hexadecimal)

sys set nvm 100 FF

stores the value 0xFF at address 0x100 of the user partition in the EEPROM

IoT device design

With its serial interface, the RN2903 requires few additional components to implement a LoRaWAN-compliant IoT hardware design. Microchip further speeds  development with its RN2903 LoRa Mote. Intended to demonstrate its LoRa module capabilities, the Microchip LoRa Mote provides a complete set of hardware and software needed to implement a LoRaWAN-compatible wireless sensor.

The Microchip RN2903 LoRa Mote and RN2483 LoRa Mote each combine the respective LoRa module with a Microchip PIC18LF45K50 8-bit MCU, which serves as host processor for sensor operation and LoRaWAN protocol execution. In addition, the Mote includes light and temperature sensors for the acquisition of sample data, as well as an LCD display for user feedback. The Mote connects to a host computer through a standard USB interface, which provides access to the LoRa module’s UART interface.

During development engineers can execute LoRaWAN operations by sending the macradio, and sys command strings to the module using the Mote’s USB connection. During runtime, code running on the IoT device host would issue commands and process responses as needed for the IoT application. For LoRaWAN applications, Microchip provides an extensive C software library with the Mote hardware. For example, an application-level routine, MOTEapp.c, collects sensor data and transmits the data through the LoRaWAN connection, handling the low-level mac commands expected by the RN2903 (Listing 1).

            . . .

            moteApp_clearBuffers();

            // Make Sure Port is in allowed Range

            // Prepare DataBuffer for Tx

            light = 0;

            temperature = 0;

            NOP();          

            // Measure Sensors

            moteApp_setSensorsInput();

            uint8_t sizeOfUpdate = 0;

            light = moteApp_convertSensorValue(moteApp_getLightValue());

            oled_putString(moteApp_getLightString(), 6, 1);

            sizeOfUpdate = moteApp_addToDataBuffer(moteApp_getLightString(), 4);

           

            temperature = moteApp_convertSensorValue(moteApp_getTempValue());

            temperature = ADC_TempConversion(temperature);

            moteApp_add8bToDataBuffer(temperature, 4 + moteApp_lightStringSize() + 1);

 

            // Do Normal Operation

            . . .

            // Getting Random Channel

            randomPortNum = TMR2_ReadTimer();

            . . .

            // Prepare DataBuffer for Tx

            moteApp_add8bToDataBuffer(randomPortNum, 0);

            dataBuffer[3] = 0x20;

            NOP();

            sendDataCommand("mac tx uncnf ", dataBuffer, 12);

            . . .

Listing 1: Microchip provides C software demonstrating a sample IoT application that collects data from the Mote’s light and temperature sensors, builds a message with the data (add8bToDataBuffer) and transmits the message (sendDataCommand) using the mac tx command. (Code source: Microchip Technology)

Application-level development

Along with the simplified keyword-based command approach, the Microchip LoRa modules and associated Mote development boards significantly simplify development of LoRaWAN end devices. Yet, even the system-level Mote board and its associated software address only the lowest, end-device level of the LoRaWAN hierarchy. A complete LoRaWAN-compatible network requires additional hardware components including compatible gateway(s) and a network server.

Further, in implementing an IoT application, developers must deal with the fact that the LoRa Alliance standard addresses only the lowest levels of the standard OSI stack. As a result, developers need to complete additional networking layers, starting with the OSI network layer that lies above the data link layer addressed by the LoRaWAN MAC standard.

Microchip addresses this need with a hardware and software development kit that implements a complete LoRaWAN-compatible network, including end devices, gateway, and network server. The Microchip RN2903 LoRa Network Evaluation Kit and the RN2483 LoRa Network Evaluation Kit bundle a pair of Motes with Microchip’s LoRaWAN gateway board. The board is comprised of a LoRaWAN gateway core board and an associated radio daughter card complete with antennas and cables.

On the software side, the kit uses the Microchip LoRa Technology Evaluation Suite which provides all of the software components required to fully evaluate an example LoRa system (Figure 2).

Diagram of Microchip's LoRa Network Evaluation Kit and software suite

Figure 2: Microchip’s LoRa Network Evaluation Kit and software suite implement a complete LoRaWAN network application, including end devices (Mote boards), gateway (core board), and network server (mchplora). (Image source: Microchip Technology)

The Suite provides a network server (mchplora) as a docker container designed to run on virtual machine in a development system. The gateway board connects to the development system through USB and communicates wirelessly with the Mote boards. The Mote boards connect through the development system’s USB to the java-based development utilities.

Designed to work with the Evaluation Suite, the Microchip LoRa Development Suite provides a comprehensive java suite that provides a more extensive set of services than available with the Mote C library. For example, to send a MAC transmission, the Development Suite abstracts the underlying transactions to a simple execute method of a macTX class (Listing 2).

  void macTXSendAction()

  {

    if (this.application.device.updateValueFlag)

      this.application.device.wanPojo.setData(this.data.getText());

    if (this.application.device.updateValueFlag) {

      this.application.device.wanPojo.setPortNumber(this.portNumber.getText());

    }

    ICommand macTX = CommandFactory.getCommand(CommandFactory.mactx);

    DeviceModel currDev = this.application.device;

    macTX.setDataModel(currDev);

 

    List task = new ArrayList();

    task.add(macTX);

 

    if (currDev != null)

      this.application.mvcController.execute(task);

    else

      System.err.println("Current Device not set");

  }

Listing 2: The Microchip LoRa Development Suite provides a complete LoRaWAN environment including an extensive set of java packages (jar files) that abstract LoRaWAN transactions such as mac tx to a set of simple software calls such as macTXSendAction(). (Code source: Microchip Technology)

In Listing 2, CommandFactory is a class defined in LoRaDevUtility.jar that defines

  public static String mactx = "mac tx";

and then creates an instance of the appropriate class, in this case, a macTx class object, when the factory is called as CommandFactory.mactx:

    if (command.compareTo(mactx) == 0)

      return new macTX();

The macTX.class in LoRaDevUtility.jar provides runtime configuration values and various service functions such as packet validation as well as the class’ primary utility method, execute. The execute method creates the required mac tx command string in the required format, transmits the message (WriteI2cData), and then acquires the response:

       . . .

          command = new StringBuilder().append("mac tx ").append(((DeviceModel)this.server).wanPojo.getIsConformed()).append(" ").append(((DeviceModel)this.server).wanPojo.getPortNumber()).append(" ").append(((DeviceModel)this.server).wanPojo.getData().replace("0x", "")).toString();

       . . .

        byte[] data = command.getBytes();

        ((DeviceModel)this.server).getController().transport.WriteI2cData(this.processPacket.pack(data), null, this.timeout);

 

        byte[] read = null;

        read = super.readResponseData();

Conclusion

Efficient connectivity is a fundamental requirement for IoT networks comprised of massive numbers of low-power IoT devices. LoRaWAN offers an effective IoT connectivity solution that offers long-range operation with minimal power requirements. As with any connectivity option, implementation can prove a major undertaking in itself, distracting developers from their primary focus on the IoT application itself.

Based on Microchip Technology’s RN2903 LoRa module, Microchip Technology’s LoRa Network Evaluation Kit and accompanying LoRa Development Suite provide a complete LoRaWAN application. Using this combination of pre-certified hardware and software, developers can quickly bring up an IoT connectivity solution able to achieve a 15 km wireless range and 10-year battery life.



Viewing all articles
Browse latest Browse all 764

Trending Articles