How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform

Click on the aboveTencent Cloud IoT, follow us and set as a star

Building the IoT industry ecosystem together

After the release of the TSC_WL_EVK LoRaWAN evaluation board co-branded by Tencent Cloud (STMicroelectronics, Ruixin Hengfang, Shenzhen Zhixin Cloud), many friends have successfully connected the evaluation board to the Tencent Cloud IoT development platform IoT Explorer. Regarding the upload of real-time temperature and humidity data, we will demonstrate the complete operation from unboxing to connection using the E53 expansion board based on the HTS221 temperature and humidity sensor from Zhixin Cloud, quietly informing you that this time we have also added the function of controlling the lamp switch and adjusting brightness through data download.

Now let me teach you step by step how to connect and perform the most basic functional development.

Before we start, let me explain that some project configurations and software installations in this example refer to the quick start guide document for the TencentOS Tiny customized development board EVB_WL on Githubhttps://github.com/Tencent/TencentOS-tiny/blob/master/doc/26.TencentOS_tiny_EVB_WL_Quick_Start.md. The engineering and software packages provided in this example are only intended to help users get started quickly, and the final version updates are subject to the updates from the TencentOS Tiny team on Github or similar code repositories.

Next, we will proceed with the most basic functional development in two steps:

1. Check the availability of the evaluation board and download the corresponding project files for basic configuration.
2. Create a new project on the Tencent Cloud IoT development platform IoT Explorer and configure it.

1. Check the availability of the evaluation board and download the corresponding project files for basic configuration

1. Check the availability of the evaluation board
The evaluation board you received includes the TSC_WL_EVK boardx1, a micro USB data cablex1, a 2.54mm pitch 40p pin headerx1, a 470~510MHz SMA LoRa antennax1, and PCB isolation seatsx4, as shown in the figure below. Tools that developers need to prepare include an ST-LINK or J-LINK debuggerx1, connecting Dupont wires for the boardx4, and a debugging computerx1 (install MDK-KEIL development tools, version 5.26 or above is recommended).
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
If you choose to add an E53 temperature and humidity sensor expansion board, you will have real data. Just insert the expansion board into the E53 interface of the main board (pay attention to the orientation).
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
First, we need to solder a few pin headers onto the board (at least 5 pin headers for the SWD port need to be soldered), as shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Connect the ST-LINK to the evaluation board (if the debugger has a 3.3V power supply interface, you can skip connecting the Micro USB cable for now), as shown in the figure:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Connect the ST-LINK to the USB interface of the computer and check if the power supply is normal, as shown in the figure:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
2. The schematic corresponding to the evaluation board
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
3. The interface diagram corresponding to the evaluation board
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
4. Download the project files corresponding to the evaluation board
Download the project package fromhttps://gitee.com/SmartChipCloud/loranode.
5. Install the KEIL device library package
On a computer with MDK-KEIL installed, install the downloaded STM32WLxx series device library package (Keil.STM32WLxx_DFP.1.0.2_OEM.pack) into KEIL.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
6. Check if the evaluation board is locked
Download and install stm32cubeprog from the ST website, use ST-LINK to connect to the SWD interface of the evaluation board, ensuring that the Dupont wires maintain a reliable connection, and note that stm32cubeprog currently only supports ST-LINK. Once connected, open stm32cubeprogrammer and click theConnect button in the upper right corner, and pay attention to the status of the connected device in the lower right corner and the prompts below. If there is no prompt sayingData read failed, you can directly skip to step7 for project configuration.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Click to select theOB icon button on the left and follow the flow in the figure to unlock:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
After successful unlocking, clickDisconnect to disconnect:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
7. Hardware SWD interface connection check
After downloading and extracting the project package, open the\board\RHF0M0E5_STM32WLE5xx\KEIL\lorawan directory in KEIL and open theTencentOS_Tiny.uvprojx project file (it is best that the location where the downloaded project package is extracted does not contain Chinese directories).
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
After opening the project, click theOption button to open the project options window, select the debugger as ST-Link (or J-link), and then click theSettings button on its right.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
UncheckCheck version on startup to avoid automatic version checks of ST-LINK every time it is opened, and then selectSW mode from the Port option below Target Com, clickOK to return to theproject options window, and then click theSettings button next to ST-Link Debugger to check. At this point, aSWD device number should appear below the SW Device list on the right, as shown in the figure below. The hardware has now been completely checked.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
8. Example project configuration
In the KEIL project window, select to open the Commissioning.h file in the APP directory, and modify the two lengths of the KEY highlighted to your defined keys, one length being 32bytes and the other length being 16bytes. Keys of the same length should be set to the same value. As shown in the figure:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
After setting, click theBuild button in KEIL and check if there are any error messages in the status bar below.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
If there are no compilation errors, you can now click the download and burn button to burn the compiled firmware onto the TSC_WL_EVK evaluation board.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform

2. Create a new project on the Tencent Cloud IoT development platform and configure it

Register a developer account on Tencent Cloud and create a new project on the IoT development platform.
The Tencent Cloud login interface is as follows:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
The IoT development platform URL (https://console.cloud.tencent.com/iotexplorer) and the new project connection are shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
1. Product Development
Click theNew Project button, enter the project name and description, and clickSave.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
After saving, click on the product box in the project list to enter the product development interface.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
In the product development interface, click theNew Product button.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Enter the product name information, select “Device”, “Key Authentication”, “LoRaWAN” communication method, “Custom Transparent Transmission” data protocol, and then click save.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
After saving, click to open the product you just created.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
In theData Template page, click to import the JSON template, copy and paste the following pre-prepared reference code, and click import.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
{ "version": "1.0", "profile": { "ProductId": "4TLSPG4R3C", "CategoryId": "1" }, "properties": [ { "id": "humidity", "name": "Humidity", "desc": "", "mode": "r", "define": { "type": "int", "min": "0", "max": "100", "start": "0", "step": "1", "unit": "%" }, "required": false }, { "id": "temperature", "name": "Temperature", "desc": "", "mode": "r", "define": { "type": "int", "min": "-100", "max": "155", "start": "0", "step": "1", "unit": "Celsius" }, "required": false }, { "id": "PowerSwitch", "name": "Switch", "desc": "Switch", "mode": "rw", "define": { "type": "bool", "mapping": { "0": "Off", "1": "On" } }, "required": false }, { "id": "BrightNess", "name": "Brightness", "desc": "Brightness", "mode": "rw", "define": { "type": "int", "min": "10", "max": "100", "start": "80", "step": "10", "unit": "%" }, "required": false }, { "id": "period", "name": "Reporting Period", "desc": "", "mode": "rw", "define": { "type": "int", "min": "5", "max": "20", "start": "10", "step": "1", "unit": "seconds" }, "required": false } ], "events": [], "actions": []}
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
After importing, it will look like the figure below. (You can also replace the import with creating a new function.) Click theNext button.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
The characteristics of LoRaWAN devices are not suitable for transmitting JSON data; in the device development tab, you can configure and test the raw data parsing function (conversion between raw data and JSON data formats).
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
You can refer to the parameters in the figure below for debugging data parsing, copying the reference code into theUpstream Data Parsing andDownstream Data Parsing input boxes. In theSimulation Debugging window below, you can manually input data and clickRun to see if the parsing result is correct.
The upstream data simulation debugging result is shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Reference code for upstream data parsing
function RawToProtocol(fPort, bytes) {    var data = {                "method": "report",                "clientToken" : new Date(),                "params" : {}    };    data.params.temperature = bytes[0];    data.params.humidity = bytes[1];    data.params.period = bytes[2];    data.params.PowerSwitch = bytes[3];    data.params.BrightNess = bytes[4];     return data;}
The downstream data simulation debugging result is shown in the figure below:
  • Temperature and humidity are read-only data and will not normally appear in the downstream data packet.

  • In the LoRaWAN protocol, we fix FPort and Mode to 2 and 0, and you can modify them as needed, but be sure to make corresponding modifications to the device firmware.

  • Add DATA[5] data, where bit0, 1, and 2 are used to mark the validity of the downstream data. The IoT development platform sends all data, while the Tencent Lianlian mini-program only sends modified data.

How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Reference code for downstream data parsing
function ProtocolToRaw(obj) {   var data = new Array();  data[0] = 2;// fport=2    data[1] = 0;// unconfirmed mode    data[2] = obj.params.period;     data[3]= (obj.params.PowerSwitch);    data[4]= (obj.params.BrightNess);    data[5]=0;    if (obj.params.hasOwnProperty("period"))        data[5]+= 1;    if (obj.params.hasOwnProperty("PowerSwitch"))        data[5]+= 2;    if (obj.params.hasOwnProperty("BrightNess"))        data[5]+= 4;         return data;}
The code snippet for the node device receiving data:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
After debugging, click theSubmit Button to enter the next stepInteractive Development page.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Here you can configure some settings in the interactive development, such as modifying the product image displayed in the subsequent Tencent Lianlian interface.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
In the interactive development panel editing interface, you can set and adjust some UI elements for the device in Tencent Lianlian, as shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Clicking Next can take you to theDevice Debugging interface.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Here we click theNew Device button to add the product corresponding to the evaluation board we compiled. In the pop-up window, enter the device name, DevEUI, and AppKey. Here, DevEUI is the 16-byte device number entered in the KEIL project, and AppKey is the 32-byte device key you entered. The DevEUI and AppKey shown in this screenshot are for demonstration purposes only.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
After clickingSave, the newly created device name will appear in the device list, as shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Clicking the device name on the right will take you to the online debugging interface, as shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
At this point, power on the TSC_WL_EVK evaluation board that has just been downloaded and burned with firmware, and wait a moment. You can see the data uploaded by the board in the window on the right of the device online debugging interface, as shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
If connected via a micro USB cable to the TSC_WL_EVK evaluation board and the CH340 USB to serial driver is installed, you can see the debugging information printed by the board in the computer’s serial communication assistant. If it showsend node joined, it indicates successful network access!
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
2. Data Development
Now we can create a data flow control logic in the Data Development interface to set up a simulation for high-temperature and high-humidity alarms. Click on theData Development menu on the left side of the IoT development platform page, and click on theNew Data Flow on the right.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Enter the data flow name, as shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
In the data flow editing interface, we drag theDevice Data,Data Filtering, andPublic Account Push three process boxes and connect them, as shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Click theDevice Data button to set the device data on the right, selecting the temperature information from the device, as shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Click theData Filtering button to set the data filtering on the right. Here we select the condition that the temperature is greater than or equal to 50 degrees Celsius, and then clickOK:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Click thePublic Account Push button to enter the title and content of the push, you can also input the real-time temperature information during the alarm, and clickOK, as shown in the figure:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
After setting all the conditions, we click theEnable button to start the alarm function.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
You can also add humidity alarms, push to the APP, etc.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Return to theProduct Development andDevice Debugging interface, click theQR Code of the device you just created, as shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Use WeChat to search and open theTencent Lianlian mini-program, scan the QR code that pops up in the mini-program and bind it, as shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
After successfully binding the device, you will see the device we created in the Tencent Lianlian mini-program, as shown in the figure below (P.S. The new version of the Tencent Lianlian UI has been upgraded, looking better and more practical~):
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Clicking the device name, we can view the real-time updated data status of the device, as shown in the figure below:
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
3. High Temperature and Humidity Alarm, Switch, Brightness Test
When there is no E53 temperature and humidity sensor expansion board, we simulate temperature and humidity changes in the device firmware. Now we can test real data, and we can also heat and humidify the sensor expansion board to trigger alarm messages. Additionally, we can set the alarm temperature to easily trigger values in data development.
The switch and brightness can be tested directly in Tencent Lianlian. It is important to note that the switch and brightness settings will only be sent to the device when it sends the next reported data. Interested friends can try changing the device to Class C to enhance real-time performance.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
4. LoRaWAN Gateway Management
Did you think that having an evaluation board means you can directly connect to Tencent Cloud? Not so fast, there is no peace without effort (direct connection); in fact, someone is carrying the weight forward (Tencent community network).
In the console, click on Network Management -> LoRa Gateway Management. Tencent has deployed many free LoRa gateways in Shenzhen, providing full coverage. Friends in Shenzhen can enjoy this benefit.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
If there are areas not covered temporarily, you can add them yourself, contributing to the community network for mutual benefit. The steps to add are simple, as follows:
The first step is to prepare your own LoRa gateway; there are many commercial ones on the market. If you want to connect to Tencent IoT more quickly, you can use a low-cost single-channel gateway developed by Tencent Cloud partners, which has already been set up with parameters for connection to Tencent Cloud. Just power it on and connect it to WiFi.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
The second step is to prepare the hardware, and in the console: click Add Gateway, enter the following parameters.
Name: Custom
GwEUI: It is recommended to add “FFFF” in the middle of the gateway MAC address to ensure uniqueness.
Is it public: This is up to you~
Other information should be as accurate as possible.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
The third step is to wait a moment, and you will see the gateway change from offline to online.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
To summarize briefly:
  • LoRaWAN node devices require a gateway to connect to Tencent Cloud. Tencent community LoRa gateways provide convenience, allowing you to focus on device development.

  • LoRaWAN devices are not suitable for using the common MQTT protocol for JSON data transmission on IoT platforms. The Tencent IoT development platform provides a way to convert raw data and JSON data formats to help LoRaWAN devices connect to the IoT platform more conveniently.

  • LoRaWAN Class A devices have relatively weak real-time performance, suitable for application scenarios that do not require high real-time performance but have strict power consumption requirements.

  • The STM32WL SoC uses TencentOS Tiny, which has a built-in LoRaWAN protocol stack, greatly facilitating device development.

Finally, as a bonus, you can use the IoT mini-program development SDK provided by Tencent Cloud to create a simple mini-program, allowing you to have your own style of mini-program interface. You can also design an H5 user interface, upload it to the console for use by the Tencent Lianlian mini-program.
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Continue to follow Tencent Cloud IoT for more valuable content!

The Tencent Cloud co-branded evaluation board is now listed in the partner Zhixin Cloud WeChat store
The gateway board and E53 sensor board will be listed soon
Guidance Documents:

[1] Tencent Cloud IoT Development Platform IoT Explorer:

https://cloud.tencent.com/product/iotexplorer

[2] TencentOS Tiny:

https://github.com/Tencent/TencentOS-tiny

[3] TencentOS Tiny customized development board EVB_WL quick start guide document:

https://github.com/Tencent/TencentOS-tiny/blob/master/doc/26.TencentOS_tiny_EVB_WL_Quick_Start.md

[4] Open source code repository download project package URL:

https://gitee.com/SmartChipCloud/loranode

//////////
How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform
Add IoT Assistant WeChat
Join the official Tencent Lianlian cooperation group (please note Tencent Lianlian)
For project cooperation, please follow this public account and click “Contact Us” in the menu bar to get cooperation contact information!

Previous Recommendations

The official standard Bluetooth protocol LLSync is released, BLE access & Wi-Fi configuration is faster than ever!
Tencent Cloud IoT Platform is upgraded significantly: aggregating internal capabilities to assist more industries
General version, open-source code, and application SDK three major versions are unveiled, Tencent Cloud releases Tencent Lianlian App service
The new Tencent Cloud IoT market is heavily upgraded!
Tencent Cloud is the first to layout a full-link 5G product matrix, promoting “All Things Connected”
Tencent Cloud IoT helps WeChat Pay collection speakers, with a daily message throughput reaching billions
The new features of Tencent Cloud IoT development platform are heavily launched, fully supporting 5G applications!
It’s here, it’s here… WeChat Pay is here with Tencent Cloud IoT
Tencent Lianlian reconstructs the new ecology of consumer IoT
The first batch of trusted IoT cloud platform certifications in China is announced, Tencent Cloud is on the list
You can also learn about the latest dynamics through the video number

How to Connect LoRaWAN Devices to Tencent Cloud IoT Platform

Leave a Comment