Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3552

Python • Button to restart Pi, button to restart program

$
0
0
I have come a little way since my first post. Learned more about hardware, and took a beginner python course. My current program is to monitor with temperature sensors, when too hot turn off the 5v relay, when too cold turn it back on. Every temp check displays on an LCD and writes to a file. The loop starts over every 15 minutes.

The program starts upon bootup via Cronjob tab.
It has main.py, which imports temp_read.py (to read the temperature, testing importing functions).

The program works as it should for me.

I would now like to add two physical buttons, one that will restart the Pi, another that will restart the program (in case I want to know the temperature NOW instead of waiting 15 minutes. Is restarting the correct way to go?).
This is no easy task for me it seems, as I cannot interrupt the 15 minute sleep command.

I began with an external "button monitoring program" that would restart the pi easily with a button press. But restarting a program and interrupting a sleep command is a problem. If I brute force KILL the program, the GPIO will stay active and will give an error when the program restarts.

And suggestions on entering the buttons into the mix?
I created a Github and started my first repository! I feel so grown up! This is my first repository, please let me know if I have shared it with you incorrectly.

My program: https://github.com/Bluebarrycat/autoferment.git

Statistics: Posted by BlueBarryCat — Sun Aug 18, 2024 8:55 pm



Viewing all articles
Browse latest Browse all 3552

Trending Articles