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
437 stars 104 forks source link

Start RPI when Powerup on USB #1024

Open BramWerbrouck opened 11 months ago

BramWerbrouck commented 11 months ago

Hi,

Finnaly I got my pijuice up and running. I got a script that runs on a power down (when removing the USB power from tha hat) but I'm looking for the right settings to powerup the RPI when the USB power is connected to the hat, so I don't need to push the onboard button everytime.

tvoverbeek commented 11 months ago

Set 'Wakeup-on-charge' to a very low tthreshold (e.g. 0 or 1) and check the restore option (this stores the setting in the MCU non-volatile memory). As soon as you apply external power via the PiJuice USB the firmware detects charging and because of the low threshold the 5v to the Pi is turned on and the Pi boots.

BramWerbrouck commented 11 months ago

I set the Wakeup)on-charge to 10 (after I tried 0 and 1) but I still need to press the button to startup the RPI.. The external power is (dis)connected to the PiJuice hat directly (not to the RPI)

bablokb commented 10 months ago

I have the same problem. Firmware 1.6

bablokb commented 10 months ago

Note: when I try this without a battery, it works. I.e. if I plug in USB-power, the system boots. It just does not do this if there is a battery attached.

tvoverbeek commented 10 months ago

@bablokb What is the output from this script:

#!/usr/bin/python3
from pijuice import PiJuice
pj = PiJuice(1,0x14)
print(pj.power.GetWakeUpOnCharge())

Does it match with the setting shown in the CLI/GUI?

bablokb commented 10 months ago

Reading the instructions really helps. Once you tick "restore" it works.

My suggestion is to change the gui. From an UI perspective, there is an "apply" button, and as a normal user I would expect that my settings are applied. "Restore" in contrast sounds like "restore defaults" and not "store into nvram".

You have very powerful hardware, and of course the software cannot be simple and support all options at the same time. But it should be consistent so users are not confused. This should also limit the rate of false issues. But I know that software (especially user-interfaces) is a very tedious business.

tvoverbeek commented 10 months ago

I agree with the "bad" choice of Restore. There are more problems with this feature. Querying the wakeip-on-charge threshold always returns the non-volatile value if it is defined.