ST Nucleo LoRa Sensor development board connected to Tencent Cloud IoT development platform

foreword

My friend Song B once said that potatoes are delicious, beef is delicious, and fried beef with potatoes is unpalatable no matter how you fry it.
Nucleo is fun, LoRa is fun, then Nucleo + LoRa will not disappoint.

This note uses the LoRa evaluation kit P-NUCLEO-LRWAN3 promoted by ST's original factory to complete the LoRa access experience of Tencent Cloud IoT Explorer.

This development board is also the welfare board of Tencent Cloud's 2019 IoT Innovation Building. The official use this board to do a detailed access tutorial on the product introductory document. Because most of the operations have been reflected in the official introductory guide , basically just follow the steps to complete, and the little expert will talk about some background materials that are not covered by the official documents.

Tencent Cloud IoT Explorer is a one-stop IoT development platform mainly promoted by Tencent Cloud. IoT experts learn and share from the three parts of device side development, platform function operation, and application side development, and also share some hands-on works and collections The officially released industry cooperation case helps readers better understand the entire development link. Details can be viewed here .

1 The general idea of ​​docking

Tencent's products generally have the corporate imprint of Buddhist culture, and the same is true in LoRa, without deliberately formulating some protocol specifications. The node side adopts the standard LoRaWAN protocol and CN470 frequency point specification. Although the gateway side requires the MQTT protocol in commercial projects, it also retains the standard Packet Forwarder protocol, which minimizes the access threshold for enterprises and developers. Very friendly to developers.

Therefore, on the node side, we only need to use the standard LoRaWAN protocol stack to achieve platform access.

The solution topology of this access practice is as follows:

LoRaWAN
PacketForwarder
Nucleo_LoRa_Sensor/TencentOS_tiny
Nucleo_LoRa_Gateway
腾讯云物联网开发平台

2 Node Hardware Introduction - NUCLEO LoRa Sensor

ST officially launched 3 LoRa evaluation kits, of which LRWAN1 has been discontinued, LRWAN2 is a high-frequency version, and LRWAN3 is a low-frequency version. Therefore, LRWAN3 just meets our domestic needs and is a very recommended board for LoRa entry development.

P-NUCLEO-LRWAN3 consists of node development board Nucleo LoRa Sensor and gateway development board Nucleo LoRa Gateway.

Since it is an official development evaluation board of ST, its biggest feature is that it supports ST's software resources, such as the node software package I-CUBE-LRWAN that is currently referenced by many manufacturers that is currently referenced by many manufacturers . If it is a third-party development board, you may need to work harder to adjust it when adapting to open source programs.

However, there is also a disadvantage that this version uses the MCU + serial port LoRa module method. For friends who want to debug the protocol stack, they feel a lack of fun, because the module has done everything. Later, I asked some partners, to the effect that from the actual market feedback, quite a lot of domestic manufacturers prefer the module method. Adopt mature modules, reduce the R&D investment in the protocol stack, and devote energy to high value-added application terminals.

3 Node Software Introduction - TencentOS tiny

TencentOS tiny is a real-time operating system developed by Tencent for the Internet of Things. It has the characteristics of low power consumption, low resource occupation, modularization, safety and reliability, and can effectively improve the development efficiency of IoT terminal products.

There is not much to say about business exchanges. Personally, I think TencentOS tiny's low-power framework and AT Adapter are still very grounded and easy to use.

In the official getting started guide, TencentOS tiny directly adapted the NUCLEO LoRa Sensor development board, and the default example is this LoRa temperature and humidity example.

For detailed development environment construction steps, you can view the Getting Started Guide for LoRaWAN Development Based on TencentOS tiny , including MDK software installation and configuration, ST-Link driver installation, and serial port software installation.

4 Tencent Cloud IoT Platform Operation

  1. Creating projects and temperature and humidity products The
    Tencent Cloud IoT development platform is divided into three dimensions: project->product->equipment. For example, there is a project of a smart conference room, which may contain multiple products such as human body detectors and light switches, and each product will have equipment a and equipment b.

  1. Create a data template
    A data template is the json definition of a product.

  2. Configure LoRaWAN parameters

  1. Device data parsing
    On the device development page, adjust device data parsing as needed. Due to the limited resources of LoRa-type devices, it is not suitable to directly transmit JSON format data. Using "device data analysis" can convert the device raw data into product JSON data.

  1. Create test equipment

On the device debugging page, click [New Device], and the device name is dev001. Information such as DevEUI can be obtained from the sticker on the back of the LoRa node development board.

5 Physical operation of the development board

1 Compile and download

Step 1. Download the LoRaWAN example

  1. Please download TencentOS tiny official open source warehouse to download source code .
  2. Enter the <TencentOS-tiny\board\NUCLEO_STM32L073RZ\KEIL\lorawan>directory and open the TencentOS_tiny.uvprojx project.
  3. The example project includes STM32L073 peripheral driver, TencentOS tiny kernel, AT framework, RHF76 LoRaWAN module driver, and LoRaWAN example case.

Step 2. Code modification

  1. Please modify first \examples\LoRaWAN\lora_demo.c..
tos_lora_module_join_otaa("8cf957200000f806", "8cf957200000f8061b39aaaaad204a72");

Fill in the corresponding DevEUI and AppKEY of the node, which can be obtained from the sticker on the back of the LoRa node development board.
2. Modification \devices\rhf76_lora\RHF76.h.

#define RHF76_ATCMD_SET_CHANNEL                 "at+ch=num,0-7\r\n"

Since channels 80 - 87 are used in this example, adjust to:

#define RHF76_ATCMD_SET_CHANNEL                 "at+ch=num,80-87\r\n"

Step 3. Compile
Click [Rebuild All] on the MDK toolbar to compile the entire project.

Step 4. Download
Click [Download] on the MDK toolbar to download the compiled firmware.

2 node networking

Node networking needs to rely on the construction of the LoRa gateway, which will be introduced in another section of notes.

  1. After the node has downloaded the firmware, it will restart automatically, and you can view the operation log of the device from the serial port.
  2. When you see the following log printed on the serial port, it means that the LoRa node has successfully entered the network through the gateway.
--->+JOIN: Network joined
--->+JOIN: NetID 000035 DevAddr 6B:CC:9B:5D

3-node uplink test

Go to [Console] > [Product Development] > [Device Debugging], and click [Device Properties] to query the latest data and historical data reported by the device to the development platform.

4 Node Downlink Test

In the console [Device Debugging] list, click [Debug] to enter online debugging.

Set the Reporting Period to 15 seconds, and click Send.

Since the LoRa node in this example is a LoRaWAN Class A device, this type of device will not send data immediately, and the server will only download data to the device after there is data upstream. Therefore, after the LoRa node reports the data, the issued cycle adjustment command can be viewed.

The serial port of the LoRa node will display the following log, indicating that the command has been successfully sent to the device.

rhf76_incoming_data_process 4: 0F00
len: 2
data[0]: 15
data[1]: 0
report_period: 15

Error prone key duplication error

Logically speaking, this example is relatively simple, but some partners still encounter problems. Several friends in the IoT competition group encountered the problem of network failure, which is basically caused by the mismatch between deveui and appkey, because deveui and appkey are copied from the stickers of the development board, so there may be mistakes .

At that time, a partner in the group sent a screenshot of the key, saying that it was no problem. I instinctively used the big explosion of the mobile phone with the hammer, and blew the characters out, only to find that there was a missing character.

END

That’s all


Related Posts