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

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 mac, radio, 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).

Copy

            . . .

            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).

Copy

  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:

Copy

       . . .

          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.

  • LoRaWAN Part 2: How to Use Microchip’s Modules to Speed IoT Design已关闭评论
    A+
发布日期:2019年07月14日  所属分类:参考设计