From 05c3f1d68e2028ee6c3224fca3aab69bedfbace3 Mon Sep 17 00:00:00 2001 From: jerick Date: Mon, 28 Nov 2022 16:17:30 -0500 Subject: [PATCH] Changing Connection location --- mqtt/tempSensor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mqtt/tempSensor.py b/mqtt/tempSensor.py index 3ad2836..7013730 100644 --- a/mqtt/tempSensor.py +++ b/mqtt/tempSensor.py @@ -94,11 +94,12 @@ def publish(client, temp, humidity): time.sleep(5.0) - -client = connect_mqtt() -client.loop_start() print (sensor) while True: + client = connect_mqtt() + client.loop_start() temp, humidity = getValues(sensor) publish(client, temp, humidity) time.sleep (5.0) + client.loop_stop() #Stop loop + client.disconnect() # disconnect