PiSupply / PiJuice

Resources for PiJuice HAT for Raspberry Pi - use your Pi Anywhere
https://uk.pi-supply.com/collections/pijuice/products/pijuice-portable-power-raspberry-pi
GNU General Public License v3.0
438 stars 104 forks source link

shutdown bug with system tasks (pijuice self restarts) #834

Open OhSoGood opened 2 years ago

OhSoGood commented 2 years ago

Hi,

I intermittently face the same issue on all my platforms (I have 40+, see details below): when I switch power off for the pijuice, either by script (with a pijuice.power.SetPowerOff(20) followed by a os.system("sudo halt") ), or by long pressing 20 seconds the SW1 button, the power gets off as expected and then comes back on a few seconds after. This is only happening when both 1. systems tasks are enabled, 2. USB power cable is connected to the pijuice and 3. I have a second hat on the raspberry (a Waveshare Sim7600E-H 4G modem). Most of the time during my tests, the battery is between 95 and 100% charged.

Once it happens on a platform, it will continue to happen forever: I cannot turn it off anymore. To kind of "solve" it, I can either remove the USB power cable from the pijuice, remove the 4G hat, but that's not a solution all the more as, as soon as I plug them back, the issue arises again. Or a third solution is to uncheck everything under System Task, to reboot the pijuice (I ignore if that's necessary), and to set back System Tasks options, in which case the issue will vanish... for a while, sometimes several days.

The bug like the hacks to fix it do not seem very logical, but that's the best I found so far.

Can anybody help? Thank you!

My platform runs on Raspberry Pi Lite of January 2022 (with debian Buster 10.11), with either pijuice 1.7 (and firmware 1.5) or pijuice 1.8 (and firmware 1.6). The Waveshare 7600EX 4G modem required "dtoverlay=i2c-rtc,ds1307" in /boot/config.txt (confirmed by a "UU" with "i2cdetect -y 1"). The only changes to the default settings in pijuice config are:

khufkens commented 2 years ago

Had similar issues and setting:

pj.power.SetWakeUpOnCharge(100)

kind of solved it a hackish way.

This assumes that your needs are purely driven by alarm based events.

tvoverbeek commented 2 years ago

As @khufkens writes your problem is the wakeup-on -charge setting: Wakeup on charge: checked. Trigger level: 15, Restore: checked With USB power to the PiJuice it detects charging and starts the Pi again. Thus Pi restarting will occur as soon as the battery charge level is above 15%. Disable the wakeup-on-charge setting (both level and restore). Why do you set it in the first place if you want the Pi to stay off?

khufkens commented 2 years ago

Because there doesn't seem to be python API call to deal with disabling it. I need control over the state of the Pi(Juice) - i.e. when a user manually alters something a script should overwrite these settings by default to create a reproducible baseline.

khufkens commented 2 years ago

Didn't see the 'DISABLED' statement... my bad.

OhSoGood commented 2 years ago

Hi,

Thank you for your answers but I honestly admit that I don't understand.

With always the same configuration, including Wakeup on charge: checked. Trigger level: 15, Restore: checked, and with the battery always charged at 95-100% plus external power plugged to the USB entry of the Pijuice, I can actually fully power off the pijuice most of the time. It's only on some seldom cases that it starts again. Whatever the actual configuration the settings lead to, it should be constant and always the same, shouldn't it?