Configuring Power OFF Timeout

This is cool. Turns out, it is super easy to enable the Red Reactor ON button to also be configured in the operating system as an OFF button, to trigger a complete and safe shutdown. But you’re probably wondering what’s special about that.

Indeed, we have already provided example Python code on our Github site that shows you how to monitor the Red Reactor ON button and use a timer to distinguish between short, medium, and a long press. And therefore, your Python code could simply execute the shutdown command after a timed press of the ON button.

And, if you have wired the Red Reactor to the Pi’s RUN port, you can guarantee that the Red Reactor’s hardware reset feature kicks in after 10 seconds in case your software is no longer responding.

But, now you can configure the operating system to also monitor the Red Reactor’s Button Interface. So you don’t need to set up any software yourself to catch the ON button press to force a safe shutdown, and you can change the button hold time to anything you like (well, less than 10 seconds anyway!). Even better, you can still run your own code to detect the ON button press to do other things as well!

So, simply update the /boot/config.txt file as follows from within a Terminal session.

The debounce period defines how long to press the ON button for in milliseconds, so change that as you want (I’d recommend at least a few seconds to ensure you don’t use it accidentally):

echo dtoverlay=gpio-shutdown,gpio_pin=13,debounce=3000 | sudo tee -a /boot/config.txt > /dev/null

You can check the extra line was added to the /boot/config.txt file by typing:

cat /boot/config.txt

Then reboot your Pi using:

sudo reboot now

There you have it. A quick press of the ON button starts everything up, and a 3 second press triggers a safe shutdown. We’d still recommend handling the shutdown from within your own application, but if you can’t do that, this does just the trick.

We think that’s cool, and hope you like it too!

One thought on “Configuring Power OFF

  1. Charlie says:

    That’s super useful and easy to integrate into an end-product. I am going to give that a try on my next build.

Leave a Reply

Your email address will not be published. Required fields are marked *

9 + 14 =