From 56a9db3691dd35babafa68346b26221d87807255 Mon Sep 17 00:00:00 2001 From: Adolfo Delorenzo Date: Fri, 19 Jul 2024 14:29:45 -0600 Subject: [PATCH] 2024-07-19 - --- .modbus_door.py.swp | Bin 1024 -> 1024 bytes modbus_door.py | 9 ++++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.modbus_door.py.swp b/.modbus_door.py.swp index 2a4e8276ae29c2c3d845f5e697e55b72d4ed6c25..972d611e9106ea8c6a064b90ae256e75bfbe25fa 100644 GIT binary patch delta 20 bcmZqRXyBM2!RD*Rz)+Amu~BWK%N}L`IG+Xg delta 20 bcmZqRXyBM2!Dgw-z)+Amu~BWK%N}L`H;)D4 diff --git a/modbus_door.py b/modbus_door.py index 9a487ab..9097493 100644 --- a/modbus_door.py +++ b/modbus_door.py @@ -28,12 +28,18 @@ sensy_boi.close_port_after_each_call = True # GPIO configuration GPIO.setmode(GPIO.BCM) -GPIO.setup(17, GPIO.IN) +# Define pin numbers +PIN_17 = 17 + +# Set GPIO +GPIO.setup(PIN_17, GPIO.IN) try: while True: + status_17 = GPIO.input(PIN_17) if GPIO.input(17) == GPIO.HIGH: + print("Adquiriendo datos...") # Read data from multiple registers @@ -48,6 +54,7 @@ try: client.publish("iiot/"+ myhost +"/temperature", temp) client.publish("iiot/"+ myhost +"/humidity", hum) + client.publish(f"iiot/{myhost}/door/pin17", str(status_17)) # Print the processed data print("-------------------------------------")