Connecting 4G Modules to Alibaba Cloud IoT Devices

Recently, I have been busy adapting 4G modules to connect with IoT devices on Alibaba Cloud, enabling normal connections for online status, subscription, unsubscription, and publishing various functionalities. Ultimately, this is implemented in a small program that includes a power meter, where the power meter controls the module to send some commands. The Alibaba Cloud platform displays all power meters for easy management, with the module and power meter communicating via serial port.Now, let’s discuss how the module is adapted to Alibaba Cloud. 1. First, create a product under the IoT module on Alibaba Cloud, and you will receive a product key and secret, which should be saved for later use. 2. Add a device under the product. Once created successfully, you can obtain the DeviceName and DeviceSecret, which should also be saved for later use. 3. Now, based on the four parameters saved earlier, create the three parameters required to log in to Alibaba Cloud: clientid, username, and password.clientid=${key}.${DeviceName}|securemode=3,signmethod=hmacsha256|username = ${DeviceName}&${key}password is derived through an algorithm, or it can also be calculated using the tools provided by Alibaba Cloud.hostname=${Key}.iot-as-mqtt.cn-shanghai.aliyuncs.comport = 1883Using the above parameters, create an MQTT instance and call the connection interface to bring the device online. 4. As a product, the deviceName is generally the IMEI number of the module to ensure uniqueness. 5. The authentication methods on the Alibaba Cloud IoT platform are divided into two types: one device one secret and one type one secret. However, as a product, one type one secret is generally chosen for convenience in burning the same firmware. During activation, the firmware reads the device’s IMEI number to ensure uniqueness. 6. The topics for subscription and publishing also follow certain rules on Alibaba Cloud: /${key}/${devicename}/user/get In recent development, both pure code writing and AT commands have been adapted, allowing everyone to communicate and learn from each other.

Leave a Comment