LoRaWAN – End-nodes

LoRaWAN End-Nodes (Devices)

LoRaWAN enables a variety of applications based on the Sensors deployed and configured on End-nodes.

Adafruit Feather M0 with Lora: LoRaWAN End-nodes

This proof-of-concept (POC) project is using AdaFruit’s “RadioFruit” – Feather M0 with RFM95 LoRa Radio (900MHz):

The AdaFruit Feather M0 LoRa Pinouts shows a very capable development board:

Your content goes here. Edit or remove this text inline or in the module Content settings. You can also style every aspect of this content in the module Design settings and even apply custom CSS to this text in the module Advanced settings.

Firmware Development

Proof of Concept firmware project name is “FeatherLora”.

Currently private on GitHub, but you can join the project.

 The FeatherLora project is tasked with development of initial proof-of-concept firmware for delivery of soil moisture and temperature sensor data over LoRaWAN.

Software (firmware) development is using Visual Studio Code (aka vscode) with C++ Intellisense and Arduino plug-in enabled.

 

Install Arduino IDE

Note: Do not install the Windows Store app as it is too “sandboxed”.

Setup VS Code Extensions

On PC, configure VS Code for C++ using Visual Studio Toolset

Be sure to Install “Visual Studio Build Tools 2019” on your development PC.

  • Add C++ Intellisense and Arduino extensions to Visual Studio Code IDE (vscode).

Add the Adafruit Boards to Arduino

Add the Adafruit Boards URL to the Arduino IDE preferences (or using vscode):

Use Boards Manager to add:

  • Adafruit SAMD Boards

C Libraries for FeatherLora

Add the following Arduino Libraries:

  • Adafruit SHT31 v2.0.0
    • Adafruit BusIO v1.4.1
  • MCCI LoRaWAN LMIC library v3.2.0
  • RunningAverage v0.3.1 by Rob Tillaart
  • Aexonis Messaging Interface v1.0.1
    • manual (define source)

Examples:

Add the Adafruit SHT31 and BusIO Libraries

Add the Adafruit LMIC Library

Add the Arduino Include Paths for VS Code

From the VS Code Commmand Palette, select:

  • C/C++: Edit Configurations (UI)

Scroll down then add the paths to the Arduino libraries and boards, such as:

  • C:\Users\bobby\Documents\Arduino\libraries**
  • C:\Users\bobby\AppData\Local\Arduino\packages**

Aexonis Messaging Interface

Manually copy the Aexonis Messaging Interface library to the Arduino libraries folder.

Additional Setup

  • Set the Arduino Board to Feather M0
  • Select the Serial Port connected to the Arduino
  • Add arduino.path to VS Code > File > Preferences > Settings > JSON
    • “arduino.path”: “C:\Program Files (x86)\Arduino”

Getting Intellisense (VS Code) to work on Windows was very troublesome. Paths, includes, browse are the subject of another article.

This article helped clear remaining errors:

Breadboard Diagram

Use Fritzing to create an initial circuit diagram.

    Load Firmware

    Firmware is released in the FeatherLora folder of the main project.

    The RadioFruit (AdaFruit Feather M0 LoRa) firmware install uses two files:

    • FeatherLora.ino <- the Arduino Script
    • lorawanConfig.h <- unique and custom settings for th device

    For Over-the-Air Activation (OTAA), it is necessary to have unique settings for each device.

    lorawanConfig.h

    This file contains the LoRaWAN settings for the device. Example:

    // file lorawanConfig.h.example
    #ifndef FEATHER_LORA_CONFIG_H_
    #define FEATHER_LORA_CONFIG_H_
    
    //#define DEBUG
    
    //LoRaWAN OTAA Settings
    #define DEVEUIBYTES { 0xbf, 0x63, 0x22, 0x00, 0x00, 0xb6, 0x76, 0x98, }
    #define APPEUIBYTES { 0x06, 0xB0, 0x22, 0x22, 0xAA, 0xF5, 0x91, 0x98, }
    #define APPKEYBYTES { 0x99, 0x80, 0x09, 0x02, 0x3A, 0xBD, 0x4F, 0xAA, 0x99, 0x89, 0x99, 0x02, 0x31, 0x23, 0x4F, 0xAA, }
    
    // 15 minutes = 900 seconds
    #define REPORT_INTERVAL 900
    
    // uncomment this for a DHT11 T/RH Sensor on A1
    //#define PANEL_DHT11
    
    #endif

     

    Header Builder: builder/build1.py

    Use this python script to build lorawanConfig.h headers from hex input strings.

    The lorwanConfig.h file uses a text representation of the Hex strings, some in little-endian. Use the script provided to save time and parse your hex strings into the config files for OTAA support on the device.

    Build Example:

    FeatherLora/builder/build1.py
    
    -- FeatherLoRa Sketch Builder --
     >> Source Folder [default: FeatherLora/]:
    
    -- Feather LoRa Sketch Builder --
      DEVEUI Hex String
      - Must be 8 bytes (16 hex digits): 9876b600001162bb
        devEuiBytes: { 0xbb, 0x62, 0x11, 0x00, 0x00, 0xb6, 0x76, 0x98, }
      APPEUI Hex String
      - Must be 8 bytes (16 hex digits): 9879F5092233B004
        appEuiBytes: { 0x04, 0xB0, 0x33, 0x22, 0x09, 0xF5, 0x79, 0x98, }
      APPKEY Hex String
      - Must be 16 bytes (32 hex digits): 998009023ABD4FAA9989990231234F0C
        appKeyBytes: { 0x99, 0x80, 0x09, 0x02, 0x3A, 0xBD, 0x4F, 0xAA, 0x99, 0x89, 0x99, 0x02, 0x31, 0x23, 0x4F, 0x0C, }
     >> Destination Folder [default: FeatherLora/build/9876b600001162bf]:

    This script produces a folder with FeatherLora.ino and the per-device lorawanConfig.h header file.

    The next step is to deploy this firmware to the RadioFruit device.

    Deployment note:

    • This script expects an SHT31 or it will freeze. You can set #define PANEL_DHT11 in the header to prevent this.
    LoRaWAN Data Journey - A Trip Report