Fixed pin clearing

This commit is contained in:
2022-11-28 16:11:53 -05:00
parent 5d6c2ac555
commit 09c6e5c786

View File

@@ -16,6 +16,11 @@ password = 'falrenforbreakfast'
client_id = f'python-mqtt-office-{random.randint(0, 1000)}'
#We first check if a libgpiod process is running. If yes, we kill it!
for proc in psutil.process_iter():
if proc.name() == 'libgpiod_pulsein' or proc.name() == 'libgpiod_pulsei':
proc.kill()
#D20 is the pin number, DHT11 is the sensor type
sensor = adafruit_dht.DHT11(board.D20)
@@ -89,14 +94,11 @@ def publish(client, temp, humidity):
time.sleep(5.0)
# We first check if a libgpiod process is running. If yes, we kill it!
# for proc in psutil.process_iter():
# if proc.name() == 'libgpiod_pulsein' or proc.name() == 'libgpiod_pulsei':
# proc.kill()
#time.sleep(1.0)
client = connect_mqtt()
client.loop_start()
print (sensor)
temp, humidity = getValues(sensor)
publish(client, temp, humidity)
while True:
temp, humidity = getValues(sensor)
publish(client, temp, humidity)
time.sleep (5.0)