PiSupply / PiJuice

Resources for PiJuice HAT for Raspberry Pi - use your Pi Anywhere
https://www.pi-supply.com/product/pijuice-standard/
GNU General Public License v3.0
433 stars 102 forks source link

Powering off PI juice when power is still connected #1028

Open lmiles-sosub opened 8 months ago

lmiles-sosub commented 8 months ago

I am having problems resolving a bit of an edge case situation with our robotic system the Pijuice is running in and hoping to get some advice.

The PiJuice is used in an ROV to handle very short momentary power outages (200ms) . There is a physical switch that controls power to the ROV which is used to power the system up and down. I have the PiJuice configured so if the the power is disconnected for more the 10 seconds it will run the following commands.

    print('Remove power to PiJuice MCU IO pins')
    self.pijuice.power.SetSystemPowerSwitch(0)

    print('set wake up charge')
    self.pijuice.power.SetWakeUpOnCharge(0.0)

    self.pijuice.config.SetLedConfiguration('D2', self.offconfig)

    print('set power off in 30 seconds')
    self.pijuice.power.SetPowerOff(30)

    print('halting Pi')
    os.system("sudo halt")

This works as expected, however in the edge case that the power switch is turned on again during the shutdown process the PiJuice will not shutoff it power even if the power is disconnected again. This results in the pi being unrecoverable until the SW1 pin is held down.

I have tried implementing the watch dog that will catch this lock up but it will only work once power is disconnected again and it will reboot the pi when I need it to just turn the out put of the HAT off and set wake on charge to true.

Is it possible to alter the firmware of the HAT to change what operation the watch dog does?

Any advice would be greatly appreciated. Thank you.