Skip to content
Advertisement

Countdown thread RPi stop if GPIO input change

I’m not sure the best way to do this, and is not working for my as it will lock the program on when its asleep not sure how to make it works right…

Im trying to monitor when a door open and closes with a raspberry Pi if there door is open for more than x time send some sort of alert (like and email), I’ve the problem that when the door closes before the countdown finished it wont stop the countdown, which causes the thread to halt, also havent implemented the alert side of thing but if the code is as at the moment it will trigger the alert even if the door closes before countdown.

At the moment I’m using a push button instead of a door sensor for testing, , also eventually i will log the opening and closing of the door, but for now id like to know if there is a nicer way of doing this, i got the code im using from this post

my code is as follows

JavaScript

Update:

Looks like I need to be using threading.Event and wait could someone advise how to implement this on my code?

Advertisement

Answer

I think i got a working script

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement