“STM32 + LoRa” Preparation & Config Parameters

简体中文

LoRa Node 151 is based on STM32L151CCU6, Turtle Board is based on STM32L432KC, Our company is gradually replacing the IDE to STM32CubeIDE, which is the STMicroelectronics official just launched development tools for their own MCUs. Based on Eclipse, include code tracking, code completion, compilation, download, single-step debugging, and integrated with CubdeMX.

Summary

No matter what LoRa management platform is used, DevEui, AppKey, etc. parameters are must needed. And ensure that it is consistent with the relevant settings on the server.

  • The following parameters are essential for OTAA mode:
    • DevEui – Mote device IEEE EUI (big endian), 8 bytes;
    • AppEui – Application IEEE EUI (big endian), 8 bytes;
    • AppKey – AES encryption/decryption cipher application key, 16 bytes;
  • The following parameters are essential for ABP mode:
    • NwkSKey – AES encryption/decryption cipher network session key, 16 bytes;
    • AppSKey – AES encryption/decryption cipher application session key, 16 bytes;
    • DevAddr – Device address on the network (big endian), uint32_t;

 

Preparation

 

Config steps

The LoRaWAN example code of LoRa Node is a STM32CubeIDE project, here is the basic config steps.

  • Download and install STM32CubeIDE and STM32CubeProgramme correctly.
  • Double click .project document, open project

The first time you run, may have the following dialog box will, click Yes and then OK.

../../_images/0143.png

../../_images/0232.png

 

  • Modify DEVICE_EUI, APPLICATION_KEY, APPLICATION_EUI in the Commissioning.h file according to your needs

../../_images/0327.png

  • Note this macro definition:
    • OVER_THE_AIR_ACTIVATION – 1:OTAA mode
    • OVER_THE_AIR_ACTIVATION – 0:ABP mode

../../_images/0710.png

 

  • Set the working bands in the macro definition.(Right-click the project to open Properties)

../../_images/0419.png

The content in the red box can only be one of the following bands:

USE_BAND_433 USE_BAND_470 USE_BAND_470PREQUEL USE_BAND_780 USE_BAND_868 USE_BAND_915 USE_BAND_915_HYBRID

  • Ensure that the listening frequency of the gateway is the same as the transmitting frequency of the node

The code for the node transmit frequency is in the LoRaMac.c file.

../../_images/0515.png

Now, if download the program into your board, if everything is normal, it should be able to run.