Stage 1: Building Your Sensor Node

Stage 1: Building Your Sensor Node


Set Up Arduino IDE

  1. Download and install the latest Arduino IDE (1.8.13 at time of writing).
  2. Open the Arduino IDE.
  3. At the Arduino IDE menu, select: Sketch > Include Library > Manage Libraries.
  4. Search for MCCI LoRaWAN LMIC and install the MCCI LoRaWAN LMIC library by IBM, Matthijs Kooijman, and others. At the time of this writing, the latest version is 3.2.0.

Figure 2: Arduino IDE Library Manager showing the installed LMIC library

  1. At the menu, select Tools > Board > Arduino Uno (or whichever board you are using for this tutorial), to ensure that the correct board is selected.
  2. The LMIC library contains a flag for toggling between region frequencies. You need to make sure the correct frequency is selected for your region. If you are in the US, you do not need to perform the remaining steps in this section, since the library defaults to the US region.
  3. At the Arduino IDE menu select Arduino > Preferences > Settings on macOSor File > Preferences on Windows and Linux. Locate the Sketchbook location field; we will refer to this as {path to sketchbook location}.

    On macOS the default location is: /Users/{username}/Documents/Arduino
    On Windows: C:\Users\{username}\Documents\Arduino
    On Linux: /home/Sketchbook.

Figure 3: Arduino IDE settings screen showing Sketchbook location

  1. Open your favorite code editor, or install Visual Studio Code.
     
  2. Open the file at {path to sketchbook location}/libraries/MCCI_LoRaWAN_LMIC_library/project_config/lmic_project_config.h. This file contains the settings for the LMIC library.
     
  3. Edit lmic_project_config.h to comment the #define CFG_us915 1 line, and uncomment the frequency for your country/region.
    The frequencies for each region are:
    - CFG_eu868 – EU
    - CFG_us915 – US
    - CFG_au915 – Australia
    - CFG_as923 – Asia
    - CFG_in866 - India
    - CFG_kr920 – South Korea

    For example, to use the EU frequency, comment and uncomment as follows:

// project-specific definitions

#define CFG_eu868 1

//#define CFG_us915 1

//#define CFG_au915 1

//#define CFG_as923 1

//#define LMIC_COUNTRY_CODE LMIC_COUNTRY_CODE_JP /* for as923-JP */

//#define CFG_kr920 1

//#define CFG_in866 1

  1. Save the lmic_project_config.h file.