5

I'm trying to utilize a Pi on a high altitude balloon where I just stick the pi in and go, when I get it back though to shut it down...is there a safe way without access to monitor, keyboard, etc?

It seems when I turn on Pi, let it run, and THEN plug in an ethernet cable, it won't connect oto the network properly

syb0rg
  • 8,188
  • 4
  • 37
  • 51
dshaw
  • 51
  • 1
  • 2
  • 1
    Near duplicate of http://raspberrypi.stackexchange.com/questions/4719/how-to-shut-down-rpi-when-running-headless/ – goldilocks Apr 10 '13 at 20:22
  • 1
    I think you might want to look to a solution for your "won't connect to the network" issue. That's annoying, and if you fix that, your shutdown problem is done for as well – Nanne Apr 11 '13 at 07:00

4 Answers4

7

If there is anything at all attached to the usb ports, you can use a udev rule such that unplugging the device will trigger a clean shutdown. I've already written a summary of the process, so I won't repeat it here. You could also do this with regard to an ethernet cable.

goldilocks
  • 58,859
  • 17
  • 112
  • 227
5

You could run a script, perhaps in Python or C that checks the status of a GPIO pin and then connect up a push button to that GPIO pin. Then when the button is pressed, the script could trigger the shutdown.

recantha
  • 4,489
  • 20
  • 26
1

Assuming you know roughly how long the pi needs to run (battery capacity etc), just have a process that sleeps for X seconds and then shuts it down.

John La Rooy
  • 11,947
  • 9
  • 47
  • 75
1

I like the button on the GPIO option to force a shutdown but I would not actually install a button for the flight I would leave the pins disconnected and jumper them once on the ground -- no chance to accidentally press the button while in flight.

I assume you are using the Pi for data collection which mean you probably don't want to lose data even if the power is lost during the flight.

I would look into setting up your system in a way that minimizes the chance of data loss if power is lost -- that way you don't need to worry too much if it is shutdown properly.

See this question for some ideas: https://serverfault.com/questions/356507/safe-ext4-configuration-for-systems-running-unattended

Craig
  • 3,014
  • 13
  • 15