feat: add a new 485 type weather station
This commit is contained in:
parent
686cf8847e
commit
5f0aed7258
@ -271,14 +271,16 @@ func ParseWH65LPData(data []byte) (*WH65LPData, error) {
|
|||||||
wd.LowBattery = (data[3]>>4)&0x01 == 1
|
wd.LowBattery = (data[3]>>4)&0x01 == 1
|
||||||
|
|
||||||
// 7. 温度 (bits 29-39) - 11位数据
|
// 7. 温度 (bits 29-39) - 11位数据
|
||||||
// 从第4字节的高3位 + 第5字节的完整8位
|
// 协议说明:温度数据实际上是从第4字节的低4位开始 + 第5字节的低3位
|
||||||
tempLow := uint16(data[4]) // bits 29-36 (实际是32-39)
|
// 但根据示例数据分析,应该是:第4字节完整8位 + 第5字节低3位
|
||||||
tempHigh := uint16((data[3] >> 5) & 0x07) // bits 29-31
|
tempLow := uint16(data[4]) // 第4字节的8位
|
||||||
|
tempHigh := uint16(data[5] & 0x07) // 第5字节的低3位
|
||||||
tempRaw := tempLow | (tempHigh << 8)
|
tempRaw := tempLow | (tempHigh << 8)
|
||||||
wd.Temperature = float64(tempRaw-400) / 10.0
|
wd.Temperature = float64(tempRaw-400) / 10.0
|
||||||
|
|
||||||
// 8. 湿度 (bits 40-47)
|
// 8. 湿度 (bits 40-47)
|
||||||
wd.Humidity = int(data[5])
|
// 湿度应该是第5字节的高5位
|
||||||
|
wd.Humidity = int(data[5] >> 3)
|
||||||
|
|
||||||
// 9. 风速 (bits 48-55 + WSP_9,WSP_8)
|
// 9. 风速 (bits 48-55 + WSP_9,WSP_8)
|
||||||
windSpeedLow := uint16(data[6]) // bits 48-55
|
windSpeedLow := uint16(data[6]) // bits 48-55
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user