LoRa Basics™ Modems: Walk-through
LoRa Basics™ Modem¶
The LoRa Basics™ Modem is an easy-to-use LoRaWAN® stack designed by Semtech. Published as an open-source software library, it enables communication between an Internet of Things (IoT) device built with a LoRa® chip and, optionally, Semtech’s LoRa Cloud™ services.
LoRa Basics Modem for 2.4GHz communication emulates the LoRaWAN Standard, but uses the 2.4GHz ISM band to allow worldwide operation and interoperability. It is also designed to run on any host microcontroller unit (MCU) together with an end-device application, making it simple to integrate with a custom platform and use case.
LoRa Basics™ Modem features two simple-to-use interfaces:
The Software API that your firmware can call directly for modem configuration, wireless communication, and access to high-level LoRa Cloud™ services
The MCU Hardware Abstraction Layer (HAL) that allows the simple adaptation of the Modem to an MCU
The modem then takes care of everything else: from managing timing to resource planning and allocation, from allowing the radio to access the device to accessing the LoRa Cloud Modem & Geolocation Services provided through Semtech’s LoRa Cloud portal. All of this with a fully open-source software architecture intended to facilitate the evolution of the software toward the integration of new features, services, and even future MAC protocols.
An efficient multi-protocol-stack feature has been implemented, one that uses a dedicated radio planner. This simplifies radio resource management by preventing direct access to the low-level radio drivers. This innovation allows multiple communication stacks to work concurrently, whilst using the same hardware resources. For even more flexibility, the modem can run either with an embedded OS or without (bare metal) allowing simple integration into a platform.
Figure 2: LoRa Basics Modem architecture
The code runs on a microcontroller, which must meet the following minimum requirements:
100 KB flash
16 KB SRAM
dedicated SPI to drive the radio chip
By default, only an ST Nucleo-L073RZ target development board is supported. To use a different board follow the porting guide available here.
Setting-up the Code¶
The software can be downloaded from Github.
Configuring the Software
In lines 97-99: enter the appropriate values for the
user_app_keyfields. (They should match values defined in Network Server Setup.)
In lines 37-38: choose either the
MAIN_EXAMPLE_EXTIapplication or the
What these applications do:
MAIN_EXAMPLE_EXTIapplication sends a temperature reading when the blue button on the Nucleo board is pressed.
MAIN_EXAMPLE_ALARM_FILE_UPLOADapplication sets up a random alarm in the 60- to 120-second range and then uploads a file when the alarm is triggered.
Compiling the Software and Programming the Modem
Compile the project using the
make -j modem_2_4 command.
This command needs the gcc-arm-non-eabi binary to be in your operating system’s path.
If this is not the case, download it from the
Arm website, extract
it on your computer (ex:
c:\gcc-arm-non-eabi), and run the command
make -j GCC_PATH="c:\gcc-arm-non-eabi\bin" modem_2_4
Next, copy the build_modem_2_4/soft_modem_2g4.bin file to the Nucleo board’s temporary drive.
If the drive is not mounted under Windows, the necessary ST-Link driver may be missing. To obtain this driver, visit ST’s Nucleo-L073RZ product page and download STSW-LINK009.
Running the Demo¶
By default, the modem will log events to the serial console. The connection parameters are as follows:
- Data bits
- Stop bits
- Flow control
This example sends the microprocessor temperature every time the blue button on the Nucleo board is pressed. The value is then displayed in a Node-RED graph.
This example sets an alarm to a random value between 60 and 120 seconds. When the alarm is triggered, the modem sends an event to the application, at which point a new file upload starts.