This commit is contained in:
xyj 2023-12-13 17:32:27 +08:00
parent 4c742656b4
commit 65a735227e
1 changed files with 3 additions and 5 deletions

View File

@ -49,8 +49,8 @@ def get_data():
# 二进制转换为16进制010304010802307b79
return_data_hex = str(return_data.hex())
# 对返回的数据进行解析,获取温度和湿度数据
airtemp_data = int(return_data_hex[6:10], 16) / 10
airhumi_data = int(return_data_hex[10:14], 16) / 10
airhumi_data = int(return_data_hex[6:10], 16) / 10
airtemp_data = int(return_data_hex[10:14], 16) / 10
time.sleep(5)
ser.write(co2_send)
time.sleep(1)
@ -165,10 +165,8 @@ def get_data():
# 二进制转换为16进制010304010802307b79
return_data_hex = str(return_data.hex())
# print('返回的数据转换为16进制:', return_data_hex)
print("当前风向为:", int(return_data_hex[6:10], 16) / 10) #单位mm
# print("当前风向为:", int(return_data_hex[10:14], 16) ) #单位mm
winddirection_data = int(return_data_hex[6:10], 16) / 10
winddirection_data2 = int(return_data_hex[10:14], 16)
print("当前风向为2", winddirection_data2) # 单位mm
time.sleep(5)
# print('{"name":"%d","name1":"%d"}', 123,456)
# data = [{'ngvhgv': airtemp_data}, {'nvjgvjvj':airhumi_data}]