geeekpi / upsplus

UPS Plus is a new generation of UPS power management module. It is an improved version of the original UPS prototype. It has been fixed the bug that UPS could not charge and automatically power off during work time. It can not only perform good battery power management, but also provide stable voltage output and RTC functions. At the same time,it support for FCP, AFC, SFCP fast charge protocol, support BC1.2 charging protocol, support battery terminal current/voltage monitoring and support two-way monitoring of charge and discharge. It can provide programmable PVD function. Power Voltage Detector (PVD) can be used to detect if batteries voltage is below or above configured voltage. Once this function has been enabled, it will monitoring your batteries voltage, and you can control whether or not shut down Raspberry Pi via simple bash script or python script. This function will protect your batteries from damage caused by excessive discharge. It can provide Adjustable data sampling Rate. This function allows you to adjust the data sampling rate so that you can get more detailed battery information and also it will consume some power. The data sampling information can communicate with the upper computer device through the I2C protocol. UPS Plus supports the OTA firmware upgrade function. Once there is a new firmware update, it is very convenient for you to upgrade firmware for UPS Plus. The firmware upgrade can be completed only by connecting to the Internet,and execute a python script. Support battery temperature monitoring and power-down memory function. UPS Plus can be set to automatically start the Raspberry Pi after the external power comes on. The programmable shutdown and forced restart function will provide you with a remote power-off restart management method. That means you don’t need to go Unplug the power cable or press the power button to cut off the power again. You can set the program to disconnect the power supply after a few seconds after the Raspberry Pi is shut down properly. And you can also reconnect the power supply after a forced power failure to achieve a remote power-off and restart operation. Once it was setting up, you don't need to press power button to boot up your device which is very suitable for smart home application scenarios.
https://wiki.52pi.com/index.php?title=UPS_Plus_SKU:_EP-0136
MIT License
73 stars 25 forks source link

Restart after shutdown by the OS itself (in the GUI)? #25

Closed ArjenR49 closed 3 years ago

ArjenR49 commented 3 years ago

f/w version 7 upsPlus.py running every minute and setting 0x18-0x1A registers to 0, 0, 180 respectively (watchdog function). The did a showdown from the GUI (in Raspberry OS). Pi shuts down. After some time, power is cut by the UPS. Soon batteries become fully charged as seen by 4 blue LEDs, none blinking any longer. All good ... But how to restart the Pi?

I tried pressing the UPS button, unplugging the charger, but no reaction from the Pi.

However, eventually it did start again. Ahaa, the watchdog timer must have done that.

So the UPS is not aware of the user shutting down the Pi, and therefore the UPS just goes on doing its watchdog routine and doesn't check if the user is pushing the button.

Can this maybe be changed? If, after a watchdog time-out, the user is present and pushes the button, could the 9 minutes restart delay be cut short and the Pi restart immediately?

I was getting ready to screw off the bottom plate again and remove the batteries as I thought the UPS had locked up somehow ... then a little later it was running again. Good thing I have the colourful 52Pi Ice Tower, it shows from far. (My Pi's bootloader config is such that the Pi stops the fan when it shuts down.)

Having documentation explaining that would prevent such panic ;-) I realize writing documentation takes time, but eventually such things should be documented.

ArjenR49 commented 3 years ago

I did a new test. Shut down the Pi from the Raspberry OS GUI. I didn't touch anything. After a while the UPS cut the power to the Pi. After still more time, which seemed longer than 9-10 minutes, the Pi started up again by itself.

So, if you want to shut down the Pi and have it stay off, it's not going to work as it is, with the 'watchdog settings' in upsPlus.py (and therefore in the UPS registers). How can this be solved? Taking the batteries out is not a very good solution.

nickfox-taterli commented 3 years ago

1)You can rewrite the countdown, even if counting. 2)You are writing [Restart Countdown], of course it will restart, there is another register [Shutdown Countdown] that does not restart. 3)According to the test, the button is not responding during the countdown, we will plan to improve this feature.

ArjenR49 commented 3 years ago

Following your advice, I also tested watchdog timer functionality without restart (set 0x18 to >=120, 0x19 and 0x1A to 0). It works as promised. Thank you! Restarting by pressing the button.