You should be able to redefine the program that handles the power button.
But my approach would be to have a circuit with a small Atmel's microcontroller that handles the power button and turns on and off the power to the Edison module, also sending the shutdown request to the Edison. It should sleep all time and only wake up when the button is pressed.
I think this interesting chip does what you want.
LTC2954 sends an interrupt to a microprocessor when a turn on/off button is pressed.
INT (Pin 5/Pin 8):
Open Drain Interrupt Output. After a pushbutton turn-off event is detected (tDB,OFF), the LTC2954 interrupts the system (μP) by asserting the INT pin low. The μP would perform power-down and housekeeping tasks and then assert the KILL pin low, thus releasing the enable output.
Thanks for this. It is interesting. Maybe i can use it, but not as illustrated above. The situation is the power will be cut, and i need to go on to a reserve battery until it can shutdown. So there's no possibility for a push button switch.
I'm trying to avoid the expense of building and testing my own circuit. Still looking for something off the shelf, or just using what's already built on the Edison or mini-breakout. Maybe i just have to bite the bullet and make the circuit.
You can connect your battery/supercapacitor to the battery connector. There is a program that was posted on the forum that shows the charge of a connected battery. In your daemon, you can measure the charge every minute or so. If the battery discharges too quickly or the level is below some value, you can run the poweroff command.
1 of 1 people found this helpful
We worked out something like this:
When the main power goes off, the OnMainPower GPIO goes low, which is monitored by our program which starts to close files and shutdown. When the CPU halts RESET_OUT is supposed to go low, which will turn of the FET finally, and save the reserve battery. When the main comes on again, RESET_OUT goes high again, and the reserve battery can be charged as per normal. I'll let you know if it works when we're done :-)