阿里云IoT控制台配置
1.1 开通阿里云IoT物联网套件
IoT物联网套件官网地址
1.2 创建高级版产品,选择数据透传

添加产品属性定义

自定义payload二进制格式
2.设备端代码
2.1 package.json引入sdk
2.2 应用程序代码
1.1 开通阿里云IoT物联网套件
IoT物联网套件官网地址
1.2 创建高级版产品,选择数据透传

添加产品属性定义
属性名 | 标识符 | 数据类型 |
温度 | temperature | float |
湿度 | humidity | float |

自定义payload二进制格式
1λ | 2-5λ | 6-9λ | 9-13λ |
00 | 5b0232e1 | 41200000 | 42b00000 |
command | requestId | temperature | humidity |
2.设备端代码
2.1 package.json引入sdk
- {
- }
2.2 应用程序代码
- /**
- * node iot_raw_data.js
- */
- const mqtt = require('aliyun-iot-mqtt');
- const COMMAND_REPORT = 0x00;
- //设备属性
- const options = {
- };
- //建立连接
- const client = mqtt.getAliyunIotMqttClient(options);
- //属性上报的Topic
- const topic = `/sys/${options.productKey}/${options.deviceName}/thing/model/up_raw`;
- setInterval(function() {
- }, 5 * 1000);
- function getPostData() {
- }
- //uint8
- function buffer_uint8(value) {
- }
- //int32
- function buffer_int32(value) {
- }
- //float32
- function buffer_float32(value) {
- }
3. 云端数据解析脚本配置
文章来源: 设备上报二进制数据在云端配置JS脚本解析