- 1. 一、CommunicationProtocol概述
- 2. 二、ProtocolFunction详解
- 3. 三、dataParse方法
- 4. 四、Precautions
- 5. 五、附录

一、CommunicationProtocol概述
1. 默认Communication parameters
- Baud rate:
9600 - data bit:
8 - check digit:无
- stop bit:
1(即9600/8/N/1) - 默认Device address:
0x01 - Responsetime:< 100ms
2. CRC verification
- 算法:CRC-16/Modbus(多项式
0x8005) - 校验码format:2 bytes,高位在前(如
CRC_H CRC_L)。 - 计算Tools:参考 CRCTool 或规格书第 IX 章代码。
二、ProtocolFunction详解
1. 读取Device address和固件版本
Function:获取当前Device address和固件版本号。
Requestformat(主机→Sensors)
| byte位置 | data | 说明 |
|---|---|---|
| 0 | 0xFE | 广播address(所有设备Response) |
| 1 | 0x11 | function code(读取address) |
| 2-5 | 0x00 | 固定填充 |
| 6-7 | CRC | CRC verification码 |
示例命令:
FE 11 00 00 00 01 28 06
Responseformat(Sensors→主机)
| byte位置 | data | 说明 |
|---|---|---|
| 0 | 0x01 | Device address |
| 1 | 0x11 | function code |
| 2 | 0x02 | dataLength(2 bytes) |
| 3 | 0x12 | 固件版本(如 0x12=V1.2) |
| 4 | 0x01 | 当前address |
| 5-6 | CRC | CRC verification码 |
示例Response:
01 11 02 12 01 70 5C
Parse:
- 固件版本:
V1.2 - Device address:
0x01
2. 修改Device address
Function:更改设备 Modbus address(范围 1~247)。
Requestformat(主机→Sensors)
| byte位置 | data | 说明 |
|---|---|---|
| 0 | 当前address | 原address(如 0x01) |
| 1 | 0x06 | function code(修改address) |
| 2-4 | 0x00 | 固定填充 |
| 5 | 新address | 目标address(如 0x02) |
| 6-7 | CRC | CRC verification码 |
示例命令(修改address为 0x02):
01 06 00 00 00 02 08 0B
Responseformat(Sensors→主机)
与Requestformat一致,返回修改后的addressConfirm。
示例Response:
01 06 00 00 00 02 08 0B
说明:Responsedata与Request相同表示修改成功。
3. 读取Sensorsdata
Function:读取指定register的Sensorsdata(支持单次读取多个Sensors)。
Requestformat(主机→Sensors)
| byte位置 | data | 说明 |
|---|---|---|
| 0 | Device address | 如 0x01 |
| 1 | 0x03 | function code(读取data) |
| 2-3 | starting address | registerstarting address(高位在前) |
| 4-5 | number of registers | 需读取的number of registers |
| 6-7 | CRC | CRC verification码 |
示例命令(读取All 11 个Sensorsdata):
01 03 00 00 00 0B C5 CD
Responseformat(Sensors→主机)
| byte位置 | data | 说明 |
|---|---|---|
| 0 | Device address | 如 0x01 |
| 1 | 0x03 | function code |
| 2 | dataLength | byte count(number of registers × 2) |
| 3~N | Sensorsdata | 每个register 2 bytes(高位在前) |
| N+1~N+2 | CRC | CRC verification码 |
示例Response(部分data):
01 03 16 00 96 00 64 00 32 00 30 00 28 00 1E 01 2C 00 0A 00 14 70 5C
Parse:
00 96→ eCO₂ = 150 ppm00 64→ TVOC = 100 ppb00 32→ CH₂O = 50 μg/m³- Temperature & Humiditydata:
- 湿度:
0x012C→ 300 → 300/100 = 30.0%RH - temperature:
0x000A→ 10 → 10/100 = 0.10℃
4. system参数配置(高级Function)
4.1 读取/设置Baud rate
register address:0x0103(Baud rate代码见附录表)。
读取Baud rateRequest:
01 03 01 03 00 01 CRC
设置Baud rateRequest(设为 115200):
01 06 01 03 00 07 CRC
4.2 校准Sensorsdata
register address:
- temperature校准:
0x011D - 湿度校准:
0x011C
示例命令(temperature校准 +2.5℃):
01 06 01 1D 00 FA 98 73
说明:
00 FA→ 250(即 250/100 = 2.5℃)- 负值需转换为补码(如
0xFF9C→ -100 → -1.00℃)。
三、dataParse方法
1. 计算公式
| SensorsType | 公式 | 示例 |
|---|---|---|
| eCO₂ | CO₂ = (CO₂_H << 8) + CO₂_L | 0x0096 → 150 ppm |
| temperature | temperature = 有符号值 / 100 | 0xFF9C → -100 → -1.00℃ |
| Illuminance | Lux = (Lux_H << 8) + Lux_L | 0x01F4 → 500 Lux |
2. 有符号数处理
- 方法 1:直接转为有符号整数(如
0xFF9C→ -100)。 - 方法 2:若值 > 32767,则
真实值 = (原始值 - 65536) / 100。
四、Precautions
- 预热time:VOC 模块需预热 ≥3 分钟,其他Sensors上电即用。
- Installation requirements:
- 安装高度 ≥15cm,避免地面尘埃污染。
- 避免高粉尘(>300 μg/m³)、油烟或高湿度环境。
- 校准警告:
- 高级Function需谨慎Operation,误修改可能导致data异常。
- 校准值需按实际环境调整,建议记录出厂默认值。
- CRC verification:所有命令必须包含正确 CRC,否则设备无Response。
五、附录
1. Sensorsregister address表
| register address | SensorsType | data format |
|---|---|---|
0x0000 | eCO₂ | 2 bytes无符号整数(ppm) |
0x0001 | TVOC | 2 bytes无符号整数(ppb) |
0x0002 | CH₂O | 2 bytes无符号整数(μg/m³) |
0x0003 | PM2.5 | 2 bytes无符号整数(μg/m³) |
0x0004 | 湿度 | 2 bytes(真实值 × 100) |
0x0005 | temperature | 2 bytes(真实值 × 100) |
0x0006 | PM10 | 2 bytes无符号整数(μg/m³) |
0x0007 | PM1.0 | 2 bytes无符号整数(μg/m³) |
0x0008 | Illuminance | 2 bytes无符号整数(Lux) |
0x0009 | MCU temperature | 2 bytes(真实值 × 100) |
0x000A | Noise | 2 bytes无符号整数(dB) |
2. Baud rate代码表
| 代码 | Baud rate |
|---|---|
0 | 1200 |
1 | 2400 |
2 | 4800 |
3 | 9600 |
4 | 19200 |
5 | 38400 |
6 | 57600 |
7 | 115200 |
3. CRC 计算代码(C 语言示例)
uint16_t CRC16_Check(const uint8_t *pushMsg, uint8_t usDataLen) {
uint8_t uchCRCHi = 0xFF, uchCRCLo = 0xFF;
uint8_t uIndex;
while (usDataLen--) {
uIndex = uchCRCLo ^ *pushMsg++;
uchCRCLo = uchCRCHi ^ auchCRCHi[uIndex];
uchCRCHi = auchCRCLo[uIndex];
}
return (uint16_t)(uchCRCHi << 8 | uchCRCLo);
}
Leave a Reply