I have a project for my raspeberry Pi. A genset monitoring when it is running and not. When genset will run it will count to 1 hour and will print another message that the genset is still running. My problem is I want to return to print genset standby without finishing the 1 hour. I place time.sleep but you need to wait for 1 hour and will still print genset is still running even the genset is already resume to standby mode for 30 mins.
import RPi.GPIO as GPIO
import time
import sys
import signal
GPIO.setmode(GPIO.BCM)
GENSET_SENSOR_PIN = 23
isOpen = None
oldIsOpen = None
GPIO.setup(DOOR_SENSOR_PIN, GPIO.IN, pull_up_down = GPIO.PUD_UP)
while True:
oldIsOpen = isOpen
isOpen = GPIO.input(GENSET_SENSOR_PIN)
if (isOpen and (isOpen != oldIsOpen)):
print ("Genset is Ok" )
elif (isOpen != oldIsOpen):
print ("Genset is Running!")
time.sleep(20)
print ("Genset is still Running!")
time.sleep(.01)
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire