Sending Simple Data to Antares

In this project you will be directed to send dummy data from STM32L072 LoRa Discovery Kit B-L072-LRWAN1 to Antares IoT Platform using LoRa connectivity with LoRaWAN protocol.

The LoRaWAN protocol is divided into two classes, Class A and Class C, each class has its own advantages and disadvantages, for more details please visit the following page.

LoRaWAN Class

Prerequisites

The required materials follow the General Prerequisites on the previous page. If you have not prepared the requirements on that page, then you can visit the following page.

General Prerequisites STM32 (LoRa) STM32Cube IDE

Follow These Steps

1. Open the STM32 Cube IDE application

2.Import LoRaWAN Project End_Node

In this section, we will explain how to import a project into the STM32 Cube IDE from the I-CUBE-LRWAN expansion software.

You can start creating an application using the STM32Cube IDE. The STM32Cube IDE uses workspaces to store the application files that we will create. You can leave it by default, or create a new workspace, as well as select a workspace that you have already created.

Selecting a Workspace in STM32CUBE IDE

After selecting the directory for the workspace, you can click the launch button until the start page of the STM32 CUBE IDE appears.

STM32CUBE IDE Home Page

To use the sample application provided by the I-CUBE-LRWAN expansion software, you can import the application provided in the expansion folder. In this example, we will use the LoRaWAN_End_Node example found in the STM32CubeExpansion_LRWAN_V2.1.0\Projects\B-L072Z-LRWAN1\Applications\LoRaWAN\LoRaWAN_End_Node\LoRaWAN\App folder.

In the next step, we need to import the project files in the STM32 Cube Expansion folder into the STM32 Cube IDE software. To import the files, click on the file and select Open Projects from File System.

Import Project

Then click Directory to select the location of the project to import. For this tutorial, the project to be imported is in the following folder: STM32CubeExpansion_LRWAN_V2.1.0\Projects\B-L072Z-LRWAN1\Applications\LoRaWAN\LoRaWAN_End_Node. After that click finish.

Directory for Import Project

After the project is successfully imported, the files in the project will be displayed on the left side of the STM32 Cube IDE as follows.

STM32 Cube IDE View after Import Project

3. Set LoRaWAN Parameters in Programme Code

This section will explain how to integrate the STM32L072 LoRa Discovery Kit board with the Antares platform.

Firstly, select the lora_app.h file located in the LoRaWAN_End_Node/LoRaWAN/App folder. The sample programme provided in the file does not yet match the LoRaWAN Indonesia frequency. Therefore, you need to customise it.

On line 43 of the programme it says LORAMAC_REGION_EU868. To adjust to the LoRaWAN frequency in Indonesia, please change that part to LORAMAC_REGION_AS923.

Programme snippet before change
Programme snippet after change

Next, select the lorawan_conf.h file located in the LoRaWAN_End_Node/LoRaWAN/Target folder. In the programme in the file there are parts that need to be adjusted which are still related to the LoRaWan frequency in Indonesia. On line 49, it can be seen that the programme code uses REGION_EU868 which is not in accordance with the LoRaWan frequency in Indonesia.

Program Code Before Customisation

So for line 49, it can be made into a comment as follows.

/*#define REGION_EU868*/

Then for this programme, REGION_AS923 is selected. So that line 44 can be uncommented as follows.

#define REGION_AS923
Program Code After Customisation

Next, add the following one line of code to the programme after the define REGION_AS923 section.

#define REGION_AS923_DEFAULT_CHANNEL_PLAN 2

Here's how the code looks after adding it.

Code Display

You can then build the application using CTRL+B, or you can choose the Project tab > Build All.

Build Project

Then to download the programme into the B-L072Z-LRWAN board, you can press F11 on the keyboard or by selecting the Run > Debug tab.

Run Debug

Then the console will say "Download verified successfully" indicating that the programme was successfully downloaded to the board.

Programme download page

Once the programme has been downloaded to the board, you can view the programme log by clicking on the open console icon in the STM32Cube IDE. Then select Command Shell Console.

Open Console

The following is a view of the Command Shell Console.

Remote Connection

Next, in Connection Type, select Serial Port.

Set Connection Type

Then in the Connection name option, press New. It can be seen that the connection name section is still empty. Because the port connection has not been registered, you can freely name this connection. For example, the connection name is COM4 (Adjusts to the serial port). Next, click finish.

Connection Name

Next, in the connection name, select COM4 that has just been added. Then, click OK.

Connection Name

Here is the view of the console. The console is still empty and does not display anything yet. It can be seen at the top of the console showing that COM4 (CONNECTED).

Communication Port Display Successfully Opened

To be able to get information from the board such as Application EUI, Device EUI, and Application Key on the console display, press the reset button of the board once until information about the board appears on the console. The following is the information of the board displayed by the console.

Information Display Board

Information from the board is used to connect the board with the Antares platform.

4. Set LoRaWAN Parameters in Antares

After logging into the Antares platform, select Application and click Create an Application.

Creating Applications in Antares

Then fill in the Application Name and Application ID. In this tutorial, let's say the Application Name is LoraSTM32 and the Application ID is 1. Then press Add.

Add Application

Next, add a device in the application. In this tutorial, the name of the device created is Lorawan. After the device is created, click Set Lora.

Set Lora

The example programme given earlier uses class A with OTAA activation mode OTAA parameters, such as Application EUI, Device EUI, and Application Key can be found in the log as shown in Figure 15.

Parameter Input on Lora Set Menu

5. Run Program

To be able to connect the board with devices on the Antares platform, click Run > Run in the STM32 CUBE IDE.

Running the program

After the programme is run, it can be seen on the console that the device is connected to the Antares platform so it says Joined as follows.

Board successfully connected to Antares Platform

6. Check Data in Antares

Setelah upload program berhasil, selanjutnya buka halaman device antares kemudian lihat apakah data lora sudah berhasil dikirim.

Data Received on the Antares Platform

Data sent from the STM32L072 LoRa Discovery Kit B-L072-LRWAN1 are "counter", "port", and a message in the JSON field "data". While other parameters are supporting parameters generated by the Antares LoRaWAN Infrastructure.

Last updated