Fixed pin clearing
This commit is contained in:
@@ -16,6 +16,11 @@ password = 'falrenforbreakfast'
|
|||||||
|
|
||||||
client_id = f'python-mqtt-office-{random.randint(0, 1000)}'
|
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
|
#D20 is the pin number, DHT11 is the sensor type
|
||||||
sensor = adafruit_dht.DHT11(board.D20)
|
sensor = adafruit_dht.DHT11(board.D20)
|
||||||
|
|
||||||
@@ -89,14 +94,11 @@ def publish(client, temp, humidity):
|
|||||||
time.sleep(5.0)
|
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 = connect_mqtt()
|
||||||
client.loop_start()
|
client.loop_start()
|
||||||
print (sensor)
|
print (sensor)
|
||||||
|
while True:
|
||||||
temp, humidity = getValues(sensor)
|
temp, humidity = getValues(sensor)
|
||||||
publish(client, temp, humidity)
|
publish(client, temp, humidity)
|
||||||
|
time.sleep (5.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user