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.
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.
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.
After selecting the directory for the workspace, you can click the launch button until the start page of the STM32 CUBE IDE appears.
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.
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.
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.
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.
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.
So for line 49, it can be made into a comment as follows.
Then for this programme, REGION_AS923 is selected. So that line 44 can be uncommented as follows.
Next, add the following one line of code to the programme after the define REGION_AS923 section.
Here's how the code looks after adding it.
You can then build the application using CTRL+B, or you can choose the Project tab > Build All.
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.
Then the console will say "Download verified successfully" indicating that the programme was successfully downloaded to the board.
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.
The following is a view of the Command Shell Console.
Next, in Connection Type, select Serial Port.
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.
Next, in the connection name, select COM4 that has just been added. Then, click OK.
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).
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 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.
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.
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.
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.
5. Run Program
To be able to connect the board with devices on the Antares platform, click Run > Run in the STM32 CUBE IDE.
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.
6. Check Data in Antares
Setelah upload program berhasil, selanjutnya buka halaman device antares kemudian lihat apakah data lora sudah berhasil dikirim.
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