This commit is contained in:
xyj 2023-12-09 15:41:05 +08:00
parent 2d139a039f
commit ef268df604
2 changed files with 49 additions and 43 deletions

View File

@ -195,27 +195,30 @@ def local():
def test(): def test():
while True: while True:
data = {'ambient_temperature': 1, try:
'ambient_humidity': 1, data = {'ambient_temperature': 1,
'carbon_dioxide': 1, 'ambient_humidity': 1,
'ambient_air_pressure': 1, 'carbon_dioxide': 1,
'ambient_lighting': 1, 'ambient_air_pressure': 1,
'soil_moisture': 1, 'ambient_lighting': 1,
'soil_temperature': 1, 'soil_moisture': 1,
'soil_conductivity': 1, 'soil_temperature': 1,
'soil_PH': 1, 'soil_conductivity': 1,
'soil_potassium_phosphate_nitrogen': 1, 'soil_PH': 1,
'soil_potassium_phosphate_phosphorus': 1, 'soil_potassium_phosphate_nitrogen': 1,
'soil_potassium_phosphate_potassium': 1, 'soil_potassium_phosphate_phosphorus': 1,
'rainfall': 1, 'soil_potassium_phosphate_potassium': 1,
'wind_speed': 1, 'rainfall': 1,
'wind_direction': 1, 'wind_speed': 1,
'create_time': int(time.time()), 'wind_direction': 1,
'device_name': device_name 'create_time': int(time.time()),
} 'device_name': device_name
t2 = LOT_DATA(**data) }
add(t2) t2 = LOT_DATA(**data)
time.sleep(1) add(t2)
time.sleep(10)
except:
pass
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -198,28 +198,31 @@ def t():
def test(): def test():
while True: while True:
data = {'ambient_temperature': 1, try:
'ambient_humidity': 1, data = {'ambient_temperature': 1,
'carbon_dioxide': 1, 'ambient_humidity': 1,
'ambient_air_pressure': 1, 'carbon_dioxide': 1,
'ambient_lighting': 1, 'ambient_air_pressure': 1,
'soil_moisture': 1, 'ambient_lighting': 1,
'soil_temperature': 1, 'soil_moisture': 1,
'soil_conductivity': 1, 'soil_temperature': 1,
'soil_PH': 1, 'soil_conductivity': 1,
'soil_potassium_phosphate_nitrogen': 1, 'soil_PH': 1,
'soil_potassium_phosphate_phosphorus': 1, 'soil_potassium_phosphate_nitrogen': 1,
'soil_potassium_phosphate_potassium': 1, 'soil_potassium_phosphate_phosphorus': 1,
'rainfall': 1, 'soil_potassium_phosphate_potassium': 1,
'wind_speed': 1, 'rainfall': 1,
'wind_direction': 1, 'wind_speed': 1,
'create_time': int(time.time()), 'wind_direction': 1,
'device_name': device_name 'create_time': int(time.time()),
} 'device_name': device_name
t2 = LOT_DATA(**data) }
client.publish('demo', payload=json.dumps(data, ensure_ascii=False), qos=0) t2 = LOT_DATA(**data)
add(t2) client.publish('demo', payload=json.dumps(data, ensure_ascii=False), qos=0)
time.sleep(1) add(t2)
time.sleep(10)
except:
pass
def on_connect(client, userdata, flags, rc): def on_connect(client, userdata, flags, rc):