On/Off power switch for R-Pi running Steve Todd JMRI image

Chris Hall Mar 5, 2021

  1. Chris Hall

    Chris Hall TrainBoard Member

    188
    410
    11
    so I've spent all evening working on this and I am at a loss.

    I've been trying to install an On/Off switch for the R-pi running Steve Todds image so I can safely turn the pi off when running headless. I've tried numerous methods, writing scripts that activate on button press, and I can get them to work using GPIO 3 (pin 5) when run manually, but any time I try to add them to the start up init.d file and update the rc.d file it just doesn't work anymore.

    I have also tried adding the dtoverlay gpio-shutdown in the config.txt file. Nothing seems to work.

    To make sure I wasn't doing something wrong, I uninstalled the JMRI image and reinstalled Raspberry Pi OS (32-bit) and the dtoverlay works a treat.

    I'm wondering if the JMRI image has something that uses a different start up system rather than the init.d and config.txt?

    Anyone able to help and shed some light?
     
  2. Chris Hall

    Chris Hall TrainBoard Member

    188
    410
    11
    Don't worry - Solved it!

    Did a fresh install of JMRI and everything seems to work now. No idea what I had done wrong.
     
  3. BigJake

    BigJake TrainBoard Member

    3,316
    6,398
    70
    It would be nice if the Wi-Throttle server and throttle apps had an option for a power-down control...

    There is an app for Android called ssh-button, or something like that, that can do it. I don't know if it is available for apple products.

    I have a VNC app on my phone that I use to shut the Pi down.
     
    Chris Hall likes this.
  4. Chris Hall

    Chris Hall TrainBoard Member

    188
    410
    11
    Yeah, that was the issue I was thinking about - I also run apple products and have yet to find something that does the same as the SSH button, so wanted a way to turn things off without having to use the iPad each time.

    Talked to Steve Todd and he just turns the pi off at the mains, said he's never had an issue with it as JMRI has very little card write activity (what really damages the SD card if you just yank the plug) so that's good to know.

    In my research I did discover that if you connect a button to ground and GPIO 3 (very conveniently pins 5/6) then you get a power on button, which is really handy. Have installed one for my test pi on my desk as I was sick of pulling the power connector out each time I wanted to power the pi up.
     
    BigJake likes this.
  5. BigJake

    BigJake TrainBoard Member

    3,316
    6,398
    70
    I'm sure Chris is aware of this, but other readers might not be:

    Grounding GPIO3 (for this OS image) does not "turn off" the R-Pi or remove power, it merely commands the OS to a state that is safe for externally removing power without corrupting files.
     

Share This Page