Sending Simple Data to Antares
In this project you will be directed to send dummy data from the STM32 LoRa Discovery Kit to the Antares IoT Platform using LoRa connectivity with the 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 ClassPrerequisites
The required materials follow the General Prerequisites on the previous page. If you have not prepared the requirements in that time, then you can visit the following page
General Prerequisites STM32 (LoRa) Arduino IDEFollow These Steps
1. Launch the Arduino IDE Application
2. Open Sample Programme
You can open the programme code in the Arduino IDE via File > Examples > Antares LoRaWAN > send-class-A-ABP.
Here is the programme code of the send-class-A-ABP example.
3. Set LoRaWAN Parameters in Antares
On the Antares Device console page, set LoRa by pressing the Set LoRa button as shown below.
Input LoRaWAN parameters with Lora Device Class A, Activation Mode ABP, ABP Parameters Inherit as shown below.
When selecting ABP Parameters Inherit, the LoRa parameters will be generated by Antares. From the device side, the Lynx32 Development Board needs to adjust the LoRa parameters.
Don't forget to save (copy) the Network Session Key and Application Session Key parameters before clicking Set LoRa to facilitate the next process.
Make sure your antares account has an active LoRa package.
4. Set LoRaWAN Parameters in Programme Code
Change the LoRaWAN ABP parameters in the following variables *devAddr, *nwkSkey, and *appsKey. Adjust to the parameters in the Antares console.
The *devAddr parameter that has been generated by Antares can be seen on the device page after completing the LoRa Set.
The parameters *nwkSKey and *appSKey are obtained during Set LoRa in the previous step.
If you forgot to save *nwkSkey and *appSKey in the previous step then look at the accesskey in your antares account then follow the following format.
5. Compile and Upload Program
Connect the STM32 LoRa Discovery Kit with your computer and make sure the Communication Port is read.
On Windows operating systems, checking can be done through the Device Manager. If your STM32 LoRa Discovery Kit is read, the STMicroelectronics STLink Virtual COM Port appears with the port adjusting the port availability (in this case it reads COM5).
Set up the STM32 LoRa Discovery Kit board by clicking Tools > Board > STM32 MCU Based Board in the Arduino IDE, then make sure the one used is Discovery. Change the Board Part Number to B-L072Z-LRWAN1. Change Upload Method to STM32CUBEProgrammer (SWD) Select the port according to the communication port that is read (in this case COM5). The result will look like the following image.
After all the setup is complete, upload the programme by pressing the arrow icon as shown below. Wait for the compile and upload process to finish
The Checklist icon in the Arduino IDE is just the verify process. Usually used to Compile the programme to find out if there are errors or not.
The Arrow icon on the Arduino IDE is the verify and upload process. Usually used to Compile the programme as well as flash the programme on the target board.
If the programme upload is successful, it will look like the following image.
After uploading the programme, you can view the serial monitor to debug the programme. The serial monitor icon is shown in the following image.
Set the serial baud rate to 115200 and select BothNL & CR. The result will look like the following image.
Make sure the serial baud rate matches the value defined in the programme code. If the serial baud rate is not the same between the programme code and the serial monitor, the ASCII characters will not be read properly.
5. Check Data in Antares
After uploading the programme successfully, then open the device antares page and see if the data has been successfully sent.
The form of the data received by the antares will be JSON in the following format
The data sent from the STM32 LoRa Discovery Kit is in the form of "counter", "port", and message in the JSON field "data". While other parameters are supporting parameters generated by the Antares LoRaWAN Infrastructure.
Last updated