This commit is contained in:
2022-11-28 16:05:58 -05:00
parent 025aa82971
commit 1d955fc15e

View File

@@ -89,17 +89,13 @@ def publish(client, temp, humidity):
time.sleep(5.0) time.sleep(5.0)
def run(sensor): # We first check if a libgpiod process is running. If yes, we kill it!
# We first check if a libgpiod process is running. If yes, we kill it! for proc in psutil.process_iter():
for proc in psutil.process_iter(): if proc.name() == 'libgpiod_pulsein' or proc.name() == 'libgpiod_pulsei':
if proc.name() == 'libgpiod_pulsein' or proc.name() == 'libgpiod_pulsei': proc.kill()
proc.kill() client = connect_mqtt()
client = connect_mqtt() client.loop_start()
client.loop_start() print (sensor)
print (sensor) while True:
while True: temp, humidity = getValues(sensor)
temp, humidity = getValues(sensor) publish(client, temp, humidity)
publish(client, temp, humidity)
#if __name__ == '__main__':
run(sensor)