LoRaWAN is getting more an more popular, both for terrestrial and increasingly with low-orbit satellite systems. The ‘Long Range’ in ‘LoRa’ makes it an ideal solution for low-power and low data rate applications. For a university research project we selected the Semtech SX1261/62 transceiver together with the NXP LPC55S16 mikrocontroller. Because the board used for that project is not available for the public (yet), I share here how you can run the LoRaWAN stack with the NXP LPC55S16-EVK.
In that research project completed by my master student Diego Bienz, devices are located in remote rural areas and do not always have connection to a terrestrial gateway. So they are able to communicate to LEO (Low Earth Orbit) satellites using the Semtech SX1262 transceiver.
The project uses the NXP LPC55S16 because of its security and low power capabilities.
Because of the current silicon shortage, the MCU is hard to get. But luckily some EVKs and evaluation boards are still available, so the LoRaWAN stack ported for this project can run on hardware still available. Unless this article now lets everyone rush ordering the last boards ;-).
Here is what you need:
- NXP LPC55S16-EVK (ARM Cortex-M33, 150 MHz, 256 KByte Flash, 96 KByte SRAM)
- SX1261MB2xAS shield (868 MHz, Mouser 947-SX1261MB2BAS).
The SX1262DVK1DAS is supported too, but more expensive:
The boards do not need any special configuration or settings.
The project is based on the official Semtech LoRaMac-node code base from GitHub. The Semtech HAL interface has been ported to the MCUXpresso SDK and the project has been created for the Eclipse based NXP MCUXpresso IDE:
The project uses build configurations to switch between different Semtech transceiver and demo applications:
Additionally it takes advantage of the Pins and Clocks tools, making it easier to port to a different mikrocontroller:
All the integration with the NXP MCUXpresso SDK is done inside the LPC55S16-EVK board folder, and can be used as a base for any other NXP boards:
The stack can be run bare-metal or with using FreeRTOS. Switching is done with a define in a configuration header file:
The project includes UART and SEGGER RTT support:
The port includes a non-volatile memory storage using the on-chip FLASH memory. The implementation has been very tricky, because the FLASH memory of the LPC55Sxx
The McuFlash module and command line interface is used for maintenance and or inspection of the FLASH memory. Additionally the MinINI module is integrated, so settings can be stored as key-value pairs in FLASH too.
LoRaWAN Device Integration
With the latest TheThingsNetwork changes and LoRaWAN stack, many existing tutorials do not work any more. So here is how to setup a device:
Create your application and end device using the console on https://www.thethingsnetwork.org/.
Manually register your end device:
Important are the DevEUI, AppKey and NwkKey which we will need to store on the device itself:
Enter these values into the se-identity.h file as below:
With this, the device shall be able to connect to the network, as shown below for the ‘periodic-uplink’ app:
There seems to be very few LoRaWAN applications and examples for NXP devices: even less taking advantage of the MCUXpresso tools. Which is a pity, because especially the LPC55Sxx devices are vary capable. The integration with FreeRTOS and the MCUXpresso SDK is not easy, especially the LPC55Sxx FLASH architecture for the storage is challenging, but very doable. I hope this example and port is useful, and LoRaWAN is used on more and more devices. All the sources are available on GitHub (see links below).
Happy LoRaWANing 🙂
- Project on GitHub: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/MCUXpresso/LPC55S16-EVK/LPC55S16_LoRaWanMacNode
- Fork LoRaMac-Node of Diego Bienz: https://github.com/nortismo/LoRaMac-node
- NXP LPC55S16-EVK: https://www.nxp.com/design/development-boards/lpcxpresso-boards/lpcxpresso55s16-development-board:LPC55S16-EVK
- SX1261/2: https://www.semtech.com/products/wireless-rf/lora-core/sx1261mb2bas
- Flash based INI: Key-Value pairs in FLASH Memory: file-system-less minINI