ST I-CUBE-LRWAN User Manual
ST I-CUBE-LRWAN User Manual

ST I-CUBE-LRWAN User Manual

Stm32 lorawan expansion package for stm32cube
Table of Contents

Advertisement

Quick Links

Introduction
This user manual describes the
STM32L1 Series, and STM32L4 Series microcontrollers. This document also explains how to interface with the LoRaWAN
®
manage the LoRa
wireless link.
®
LoRa
is a type of wireless telecommunication network designed to allow long-range communications at a very low bit-rate
and enabling long-life battery-operated sensors. LoRaWAN
interoperability with the LoRa
®
protocol named LoRaWAN
.
The I-CUBE-LRWAN main features are the following:
Integration-ready application
Easy add-on of the low-power LoRa
Extremely-low CPU load
No latency requirements
Small STM32 memory footprint
Low-power timing services provided
The I-CUBE-LRWAN Expansion Package is based on the STM32Cube HAL drivers (Refer to
This user manual provides customer examples on NUCLEO-L053R8, NUCLEO-L073RZ, NUCLEO-L152RE, and
L476RG
using Semtech expansion boards SX1276MB1MAS, SX1276MB1LAS, SX1272MB2DAS, SX1262DVK1DAS,
SX1262DVK1CAS, and SX1262DVK1BAS.
This document targets the following tools:
P-NUCLEO-LRWAN1, STM32 Nucleo pack for LoRa
P-NUCLEO-LRWAN2, STM32 Nucleo starter pack (USI
P-NUCLEO-LRWAN3, STM32 Nucleo starter pack (RisingHF) for LoRa
B-L072Z-LRWAN1, STM32 Discovery kit embedding the CMWX1ZZABZ-091 LoRa
I-NUCLEO-LRWAN1, LoRa
available in P-NUCLEO-LRWAN2
LRWAN-NS1, expansion board featuring the RisingHF modem RHF0M003 available in P-NUCLEO-LRWAN3
UM2073 - Rev 12 - September 2021
For further information contact your local STMicroelectronics sales office.
STM32 LoRaWAN
I-CUBE-LRWAN
LoRaWAN
®
®
network. The LoRaWAN
Expansion Package is compliant with the LoRa Alliance
®
solution
®
expansion board for STM32 Nucleo, based on the WM-SG-SM-42 LPWAN module (USI
®
Expansion Package for STM32Cube
®
Expansion Package implementation on the STM32L0 Series,
®
defines the communication and security protocol that ensures
®
technology (Legacy only)
®
®
) for LoRa
technology
®
technology
UM2073
User manual
®
specification
LoRa standard
overview).
NUCLEO-
®
module from Murata
®
to
®
)
www.st.com

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the I-CUBE-LRWAN and is the answer not in the manual?

Questions and answers

Summary of Contents for ST I-CUBE-LRWAN

  • Page 1 No latency requirements • Small STM32 memory footprint • Low-power timing services provided The I-CUBE-LRWAN Expansion Package is based on the STM32Cube HAL drivers (Refer to LoRa standard overview). This user manual provides customer examples on NUCLEO-L053R8, NUCLEO-L073RZ, NUCLEO-L152RE, and NUCLEO-...
  • Page 2: General Information

    UM2073 General information General information ® ® I-CUBE-LRWAN Expansion Package runs on STM32 32‑bit microcontrollers based on the Arm Cortex processor. Note: Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere. Terms and definitions...
  • Page 3: Overview Of Available Documents And References

    LoRa Alliance Application layer clock synchronization over LoRaWAN Specification v1.0.0 September 2018 [TS‑003] Application note Integration guide for the X-CUBE-SBSFU STM32Cube Expansion Package (AN5056) Application note I-CUBE-LRWAN embedding FUOTA, application implementation (AN5411) Application note Examples of AT commands on I-CUBE-LRWAN (AN4967) ® [10] Application note How to build a LoRa...
  • Page 4: Lora ® Standard Overview

    UM2073 LoRa® standard overview ® LoRa standard overview Overview ® ® This section provides a general overview of the LoRa and LoRaWAN recommendations, particularly focusing ® on the LoRa end device that is the core subject of this user manual. ®...
  • Page 5: End-Device Architecture

    UM2073 Network architecture 2.2.1 End-device architecture The end device is composed of an RF transceiver (also known as radio) and a host STM32 MCU. The RF transceiver is composed of a modem and an RF up-converter. The MCU implements the radio driver, the ®...
  • Page 6: End-Device Activation (Joining)

    UM2073 Network architecture Bi-directional Class-C end devices with maximal receive slots (continuous) • Large power consumption • Class-C end devices have nearly continuously open receive windows, only closed when transmitting (Refer Figure Figure 4. Tx/Rx time diagram (Class-C) On-air transmit time RxDelay1 RxDelay2 Extends RxC until next uplink...
  • Page 7: Regional Spectrum Allocation

    UM2073 Network architecture 2.2.4 Regional spectrum allocation ® The LoRaWAN specification varies slightly from region to region. The European, North American, and Asian regions have different spectrum allocations and regulatory requirements (Refer to Table 4 for more details). ® Table 4. LoRaWAN regional spectrum allocation Output power...
  • Page 8: Network Layer

    UM2073 Network layer Network layer ® The LoRaWAN architecture is defined in terms of blocks, also called “layers”. Each layer is responsible for one part of the standard and offers services to higher layers. The end device is at least made of one physical layer (PHY), that embeds the radio frequency transceiver, a MAC sublayer providing access to the physical channel, and an application layer, as shown in Figure ®...
  • Page 9: End-Device Class-A Data Communication

    UM2073 Message flow The message sequence chart (MSC) in Figure 6 shows the OTAA activation method. Figure 6. Message sequence chart for joining (MLME primitives) End-device End-device Network Network App layer MAC layer MAC layer App layer MLME.Req (join request) Join request MLME.Ind (join request)
  • Page 10: Figure 7. Message Sequence Chart For Confirmed Data (Mcps Primitives)

    UM2073 Message flow If the acknowledgment frame is received, then the transmission is successful, else the transmission failed. Figure 7. Message sequence chart for confirmed data (MCPS primitives) End-device End-device Network Network App layer MAC layer MAC layer App layer MCPS.Req (data request) Data (Ackreq=1)
  • Page 11: End-Device Class-B Mode Establishment

    UM2073 Message flow 2.4.3 End-device class-B mode establishment ® This section describes the LoRaWAN class-B mode establishment. Class-B is achieved by having the gateway sending a beacon on a 128 s regular basis to synchronize all the end devices in the network so that the end device can open a short Rx window called a ping slot.
  • Page 12: Data Flow

    UM2073 Data flow Data flow The data integrity is ensured by the network session key NwkSKey and the application session key AppSKey. NwkSKey is used to encrypt and decrypt the MAC payload data and AppSKey is used to encrypt and decrypt the application payload data.
  • Page 13: I-Cube-Lrwan Middleware Description

    UM2073 I-CUBE-LRWAN middleware description I-CUBE-LRWAN middleware description Overview ® This I-CUBE-LRWAN Expansion Package offers a LoRaWAN stack middleware for STM32 microcontrollers. This middleware is split into several modules: • LoRaMac layer module ® • LoRaWAN utility module ® • LoRaWAN crypto module •...
  • Page 14: Features

    UM2073 Features The I-CUBE-LRWAN Expansion Package includes: ® • The LoRaWAN stack middleware: ® – LoRaWAN layer ® – LoRaWAN utilities ® – LoRaWAN software crypto engine – LoRaMac handler state machine • Board support package: – Radio Semtech drivers –...
  • Page 15: Architecture

    UM2073 Architecture Architecture Figure 12 describes the main design of the firmware for the I-CUBE-LRWAN application. Figure 12. Main design of the firmware Application (user) LmHandler MAC layer Utilities: timer server Sensor low-power driver rand gen Crypto/ software Radio driver...
  • Page 16: Hardware Related Components

    UM2073 Hardware related components Hardware related components 3.4.1 Radio reset One GPIO from the MCU is used to reset the radio. This action is done once at the initialization of the hardware (Refer to Table 42 Section 6.1 3.4.2 The sx127x or sx126x radio commands and registers are accessed through the SPI bus at 1 Mbit/s (Refer to Table 42 Single MCU end-device hardware description).
  • Page 17: Cube-Lrwan Middleware Programming Guidelines

    UM2073 I-CUBE-LRWAN middleware programming guidelines I-CUBE-LRWAN middleware programming guidelines This section describes the LoRaMac layer APIs. The proprietary PHY layer (Refer to Section 2.1 Overview) is out of the scope of this user manual and must be viewed as a black box.
  • Page 18: Mib Services

    UM2073 Middleware MAC layer callbacks 4.2.3 MIB services The MIB stores important runtime information, such as MIB_NETWORK_ACTIVATION, or MIB_NET_ID, and ® holds the configuration of the LoRaWAN MAC layer, for example, MIB_ADR or MIB_APP_KEY. The provided APIs are presented in Table Table 8.
  • Page 19: Middleware Mac Layer Timers

    UM2073 Middleware MAC layer timers Middleware MAC layer timers 4.4.1 Rx-delay window Refer to Section 2.2.2 End-device classes. Refer to Table 12 for the Rx-delay functions. Table 12. Rx-delay functions Function Description Set the RxDelay1 void OnRxWindow1TimerEvent (void) (ReceiveDelayX - RADIO_WAKEUP_TIME) void OnRxWindow2TimerEvent (void) Set the RxDelay2 4.4.2...
  • Page 20: Middleware Lmhandler Application Function

    UM2073 Middleware LmHandler application function The APIs presented in Table 15 are used to manage the emulated secure element. Table 15. Secure-element functions Function Description SecureElementStatus_t Initialization of the secure-element driver SecureElementInit The Callback function is called when the non-volatile context must be stored.
  • Page 21: Figure 14. Operation Model

    UM2073 Middleware LmHandler application function Operational model ® The operation model proposed for this LoRaWAN End_Node (Refer to Figure 14) is based on event‑driven ® paradigms including time‑driven ones. The behavior of the LoRaWAN system is triggered either by a timer event or by a radio event plus a guard transition.
  • Page 22: Figure 15. Lorawan ® State Behavior

    UM2073 Middleware LmHandler application function ® LoRaWAN system state behavior ® Figure 15 describes the LoRaWAN End_Node system state behavior. ® On reset, after the system initialization is done, the LoRaWAN End_Node system goes into a Start state defined as Init. ®...
  • Page 23: Figure 16. Lorawan ® Class-B System State Behavior

    UM2073 Middleware LmHandler application function ® On MLME Beacon_Acquisition_req, the end-device LoRaWAN class‑B system state goes in BEACON_STATE_ACQUISITION. ® The LoRaWAN end device starts the beacon acquisition. When the MAC layer successfully receives a beacon in the RxBeacon function, the next state is BEACON_STATE_LOCKED. ®...
  • Page 24: Lora ® Initialization

    UM2073 Middleware LmHandler application function 4.6.1 ® LoRa initialization ® Table 16. LoRa initialization function Function Description LmHandlerErrorStatus_t LmHandlerInit Initialization of the LoRa finite state machine (LmHandlerCallbacks_t *handlerCallbacks) 4.6.2 ® LoRa join request entry point ® Table 17. LoRa join request entry point Function Description void LmHandlerJoin (ActivationType_t...
  • Page 25: Request The Current Network Time

    UM2073 Middleware LmHandler application function 4.6.6 Request the current network time Table 21. Current network time Function Description The end device requests the current network time from the LmHandlerErrorStatus_t network. This is useful to accelerate the beacon discovery in LmHandlerDeviceTimeReq(void) class‑B mode.
  • Page 26: Get Current Tx Data Rate

    UM2073 Library application callbacks 4.6.11 Get current Tx data rate Table 26. Get current Tx data rate Function Description int32_t LmHandlerGetTxDatarate( int8_t Gets the current Tx data rate. *txDatarate) 4.6.12 Set Tx data rate Table 27. Set Tx data rate Function Description int32_t LmHandlerSetTxDatarate( int8_t...
  • Page 27: Current Temperature Level

    UM2073 Extended application functions 4.7.2 Current temperature level Table 31. Current temperature level function Function Description Get the current temperature (degree Celsius) of the chipset in uint16_t GetTemperatureLevel (void) q7.8 format. 4.7.3 Board unique ID Table 32. Board unique ID function Function Description void GetUniqueId (uint8_t *id)
  • Page 28: Table 34. Extended Application Functions

    UM2073 Extended application functions Table 34. Extended application functions Function Description int32_t LmHandlerGetDevEUI( uint8_t *devEUI) ® Gets the LoRaWAN device EUI. int32_t LmHandlerSetDevEUI( uint8_t *devEUI) ® Sets the LoRaWAN device EUI. int32_t LmHandlerGetAppEUI( uint8_t *appEUI) ® Gets the LoRaWAN application EUI. int32_t LmHandlerSetAppEUI( uint8_t *appEUI) ®...
  • Page 29: Utilities Description

    UM2073 Utilities description Utilities description Utilities are located in the \Utilities directory. Main APIs are described below. Secondary APIs and additional information can be found on the header files related to the drivers. Sequencer The sequencer provides a robust and easy framework to execute tasks in the background and enters low-power mode when there is no more activity.
  • Page 30: Timer Server

    UM2073 Timer server The figure below compares the standard while-loop implementation with the sequencer while-loop implementation. Figure 17. While-loop standard vs. sequencer implementation Standard way Sequencer way While(1) /*Flag1 and Flag2 are bitmasks*/ UTIL_SEQ_RegTask(flag1, Fct1()); if(flag1) UTIL_SEQ_RegTask(flag2, Fct2()); flag1=0; While(1) Fct1();...
  • Page 31: Low-Power Functions

    UM2073 Low-power functions The timer server is located in Utilities\timer\stm32_timer.c. Table 36. Timer server APIs Function Description UTIL_TIMER_Status_t UTIL_TIMER_Init( void ) Initializes the timer server. UTIL_TIMER_Status_t UTIL_TIMER_Create ( UTIL_TIMER_Object_t *TimerObject, uint32_t PeriodValue, Creates the timer object and associates a callback function when timer elapses. UTIL_TIMER_Mode_t Mode, void ( *Callback ) ( void *), void *Argument) UTIL_TIMER_Status_t...
  • Page 32: System Time

    UM2073 System time Figure 18 depicts the behavior with three different firmware modules setting dependently their low-power requirements and low-power mode, selected when the system enters a low-power mode. Figure 18. Example of low-power mode dynamic view UTIL_LPM_SetStopMode((1 << CFG_LPM_MODULE0_Id), UTIL_LPM_DISABLE); UTIL_LPM_SetStopMode((1 <<...
  • Page 33: Table 39. System Time Functions

    UM2073 System time The APIs presented in the table below are used to manage the system time of the core MCU. The systime utility is located in Utilities\misc\stm32_systime.c. Table 39. System time functions Function Description Based on an input UNIX epoch in seconds and sub-seconds, the void SysTimeSet (SysTime_t sysTime) difference with the MCU time is stored in the backup register (retained even in Standby mode).
  • Page 34: Trace

    UM2073 Trace Trace The trace module enables printing data on a COM port using DMA. The APIs presented in the table below are used to manage the trace functions. The trace utility is located in Utilities\trace\adv_trace\stm32_adv_trace.c. Table 40. Trace functions Function Description TraceInit...
  • Page 35 UM2073 Trace The UTIL_ADV_TRACE_COND_FSend (..) function can be used: • in polling mode when no real time constraints apply: for example, during application initialization #define APP_PPRINTF(...) do{ } while( UTIL_ADV_TRACE_OK \ != UTIL_ADV_TRACE_COND_FSend(VLEVEL_ALWAYS, T_REG_OFF, TS_OFF, __VA_ARGS__) ) /* Polling Mode */ •...
  • Page 36: Example Description

    NUCLEO- Supported L476RG 1. This particular configuration is commercially available as a P-NUCLEO-LRWAN1 kit. The I-CUBE-LRWAN Expansion Package can easily be tailored to any other supported device and development board. ® The main characteristics of the LoRa radio expansion board are described in Table ®...
  • Page 37: Split End-Device Hardware Description (Two-Mcu Solution)

    AT_MASTER Lora modem ® AT command application LoraWAN stack ® over UART (included in radio I-CUBE-LRWAN) ® ® The interface between the LoRa modem and the LoRa host is a UART running AT commands. UM2073 - Rev 12 page 37/52...
  • Page 38: Package Description

    UM2073 Package description Package description When the user unzips the I-CUBE-LRWAN, the package presents the structure shown in Figure Figure 20. I-CUBE-LRWAN structure The I-CUBE-LRWAN Expansion Package contains five applications: LoRaWAN_AT_Master, LoRaWAN_End_ Node, LoRaWAN_AT_Slave, SubGHz_Phy_PingPong, and LoRaWAN_FUOTA (Only supported on NUCLEO- ®...
  • Page 39: End_Node Application

    UM2073 End_Node application End_Node application This application reads the temperature, humidity, and atmospheric pressure from the sensors through the I The MCU measures the supplied voltage through V to calculate the battery level. These four data REFLNT ® (temperature, humidity, atmospheric pressure, and battery level) are sent periodically to the LoRaWAN network ®...
  • Page 40: Table 44. Switch Options For Lorawan_End_Node Application Configuration

    UM2073 End_Node application Table 44. Switch options for LoRaWAN_End_Node application configuration Project Detail Switch option Definition Location dule STATIC_DEVICE_EUI Identification Static or dynamic end‑device identifying se-identity.h STATIC_DEVICE_ADDRESS Address Static or dynamic end‑device address REGION_EU868 REGION_EU433 REGION_US915 REGION_AS923 REGION_AU915 Supported regions Regions supported by the device REGION_CN470 REGION_CN779...
  • Page 41: Pingpong Application Description

    To set up the Nucleo board, connect it or the B-L072Z-LRWAN1 board to the computer with a Type-A to Mini-B USB cable to the CN1 ST-LINK connector. Ensure that the CN2 ST-LINK connector jumpers are ON. Refer to Figure 21 for a representation of the PingPong setup.
  • Page 42: Fuota Application Description

    This application is made up of Secure Boot and Secure Firmware Update (SBSFU), LoRaWAN protocol stack, and User Application [2]. This application only targets the SMT32L476RG microcontroller. The application note gives all the needed information to make use of the FUOTA I-CUBE-LRWAN part. UM2073 - Rev 12 page 42/52...
  • Page 43: System Performances

    UM2073 System performances System performances Memory footprints ® The values in Table 46 are measured for the following IAR Embedded Workbench EWARM 8.32 compiler configuration: • Optimization: Optimized for the high size level • Debug option: OFF • Trace option: OFF •...
  • Page 44: Power Consumption

    UM2073 Power consumption Power consumption The power-consumption measurement is done for the Nucleo boards associated with the SX1276MB1MAS shield. Measurements setup • No DEBUGGER_ENABLED • No TRACE • No SENSOR_ENABLED Measurement results • Typical consumption in stop mode: 1.3 μA •...
  • Page 45: Revision History

    Introduction with I-NUCLEO-LRWAN1 LoRa expansion board • Figure 10: Project files structure • Section 5.1: Single MCU end-device hardware description • Figure 15: I-CUBE-LRWAN structure • Section 5.4: End_Node application • Section Table 27.: Switch options for the application's configuration 21-Feb-2017 •...
  • Page 46 UM2073 Date Version Changes Removed: 13-Dec-2018 • Class B restriction regarding AT commands in Section 5.6: AT_Slave application description Updated: • P-NUCLEO-LPWAN2/3 in Introduction and Section 5.7:AT_Master 9-Jul-2019 application description • Added Section 2.4.3:End-device class B mode establishment Added: • FUOTA and SBSFU acronyms in Table1 4-Nov-2019 ®...
  • Page 47: Table Of Contents

    I-CUBE-LRWAN middleware description........
  • Page 48 UM2073 Contents 4.3.2 MLME ..............18 4.3.3 MIB .
  • Page 49 UM2073 Contents Split end-device hardware description (Two-MCU solution) ......37 Package description ............38 End_Node application.
  • Page 50: List Of Tables

    UM2073 List of tables List of tables Table 1. List of acronyms ..............2 Table 2.
  • Page 51: List Of Figures

    I-CUBE-LRWAN structure ........
  • Page 52 ST’s terms and conditions of sale in place at the time of order acknowledgement. Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of Purchasers’...

Table of Contents