This commit is contained in:
xyj 2023-12-02 11:51:47 +08:00
parent 985e6d0d28
commit 628ba588c5
1 changed files with 20 additions and 3 deletions

View File

@ -17,7 +17,7 @@ def print_json(data):
print(json.dumps(data, sort_keys=True, indent=4, separators=(', ', ': '), ensure_ascii=False))
def run_with_client(client):
def run_with_client():
temp_send = '06 03 01 F4 00 02 85 B2 ' # 温湿度查询指令
co2_send = '06 03 01 F7 00 02 75 B2 ' # 二氧化碳查询指令
pressure_send = '06 03 01 F9 00 02 14 71 ' # 气压查询指令
@ -401,9 +401,26 @@ def t2():
def t1():
# run_with_client(self.client)
# run_with_client()
while True:
client.publish('demo', 'test', qos=0)
data = {
"wind_speed": 26,
"wind_direction": 6,
"ambient_temperature": 66,
"ambient_humidity": 78,
"carbon_dioxide": 94,
"ambient_air_pressure": 48,
"rainfall": 3,
"ambient_lighting": 59,
"soil_temperature": 71,
"soil_moisture": 19,
"soil_conductivity": 62,
"soil_PH": 49,
"soil_potassium_phosphate_nitrogen": 5,
"soil_potassium_phosphate_phosphorus": 5,
"soil_potassium_phosphate_potassium": 86
}
client.publish('demo', payload=json.dumps(data, ensure_ascii=False), qos=0)
time.sleep(60)