[go: up one dir, main page]

Skip to content

UTFPR-IoT/ttn-hello-world

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hello world

Menu

  1. TTN configurations
    1.1 Application
    1.2 OTAA end device
    1.3 ABP end device
    1.4 Payload Formatter
  2. Software
    2.1 End devices key configuration
    2.2 LMIC library
    2.3 Heltec library
    2.4 Pinmap
  3. Hardware
    3.1 Heltec LoRa V2
    3.2 Arduino IDE configurations
  4. Other issues
  5. Credits

TTN configurations

Application

  • On Applications tab, press the blue button + Add application.
  • Set Application ID. Optionally, set an Application name and add a description.
    Application configuration on TTN
  • Finally, Create application.
  • Choose between OTAA or ABP configuration.

OTAA end device

  • Once in a application, enter End devices tab and press the blue button + Add end device.
  • Choose the Manually tab and set the option below.
Frequency plan Australia 915-928 MHz, FSB 2 (used bt TTN)
LoRaWAN Version LoRaWAN Specification 1.0.3
DevEUI can be generate automatically
AppEUI must have, at least, a non-zero digit
AppKey can be generate aumatically
End device ID An ID for the device

End device OTAA configuration on TTN

  • Finally, Register end device

ABP end device

  • Once in a application, enter End devices tab and press the blue button + Add end device.
  • Choose the Manually tab and set the option below.
Frequency plan Australia 915-928 MHz, FSB 2 (used bt TTN)
LoRaWAN Version LoRaWAN Specification 1.0.3
  • Expand the session Show advanced activation, LoRaWAN class and cluster settings
  • On Activation mode select Activation by personalization (ABP) option.
DevEUI can be generate automatically
Device address can be generate automatically
AppSKey can be generate automatically
NwkSKey can be generate automatically
End device ID An ID for the device

End device OTAA configuration on TTN

  • Finally, Register end device

Payload Formatter

  • On an end device page, go to Payload formatter tab.
  • On Uplink tab, change Formatter type to Custom JavaScript formatter.
  • Input the script below on Formater code screen.
function decodeUplink(input) {
  return {
    data: {
      msg: String.fromCharCode.apply(null, input.bytes)
    },
    warnings: [],
    errors: []
  };
}

Software

End devices key configuration

  • On main.ino, select the end device activation mode by commenting/uncommenting the option.
#define USE_OTAA
//#define USE_ABP
  • Copy and paste the end device keys on the reserverd variables (lines 13-15 to ABP or lines 22-26 to OTAA)
    important: In case of OTAA configuration the keys AppEUI and DevEUI must be in lsb format.
    • You can copy alredy formatted directly by the end device page on TTN. <> Toggle array formatting, <- -> Switch byte order

LMIC library

  • Import mcci_catena/arduino-lmic library into your project
  • On arduino-lmic/project_config/lmic_project_config.h comment the line #define CFG_us915 1 and uncomment the line //#define CFG_au915 1
    This file should be:
// 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; also define CFG_as923 */
//#define CFG_kr920 1
//#define CFG_in866 1
#define CFG_sx1276_radio 1
//#define LMIC_USE_INTERRUPTS

Heltec library

Import Heltec library directly from Arduino IDE
** Sketch > Add libraryL**
Search for Heltec esp32

Pinmap

  • Set LoRa pins on struct (lines 37-42).
const lmic_pinmap lmic_pins = {
    .nss =  ,
    .rxtx = ,
    .rst =  , 
    .dio = { , , },
};

Hardware

Heltec LoRa V2

  • The hardware used was Heltec LoRa V2.
    Heltec Lora V2 Pinout
  • The pinmap for this board is
    .nss = 18,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 14, 
    .dio = {26, 35, 34},

Arduino IDE configurations

Other issues

hal/hal.h hal_init()

  • In my tests, using Visual Code PlatformIO, I had some issues with the function hal_init() on /arduino-lmic/src/hal/hal.cpp because duplicity with another function alredy setted on Heltec Lora v2 board to PlatformIO. So I just change the name of this function and everythings worked fine.

Credits

  • This guide is based on ERRC 2021 repository developed by Francisco Pastório, A., Pedro Cardoso Amâncio de Sá, J., Tavares de Camargo, E., Alexandre Spanhol, F., Antonio Rodrigues, L., & Rossato, J. (2021). Fundamentos de LoRaWAN - Teoria e Prática [Computer software]. https://github.com/afpastorio/ERRC-2021

Releases

No releases published

Packages

No packages published