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

UPS attempted to ruin my batteries? Really more like my bad, but beware ... #75

Closed ArjenR49 closed 3 years ago

ArjenR49 commented 3 years ago

My UPS plus has f/w 9. The control script I use is Frtz13's fanShutDownUPS.py. In addition to its fan control and HA reporting it observes the same UPS functions as the GeeekPi scripts with extra's, i.e. when AC fails, it writes messages to the syslog about the battery voltage dropping and at a margin of 200 mV above the protection voltage it sets the countdown timer 0x18 register to 60 and then sends a shutdown command to the Pi.

I have had the protection voltage at 3200 mV for some time now and have run down the batteries till automatic shutdown by the UPS itself (no control script running) and reconnected AC a few times to have the UPS 'learn' the battery fully discharged value. This has been successful as I described elsewhere.

In order to find out the influence of the battery sampling interval (period) on e.g. the estimated battery capacity and charging/discharging behaviour of the UPS, I had very recently set the sampling interval to 600 instead of the default 2 minutes. I can't say if this is to blame for the mishap that happened last night after disconnecting AC.

Anyway, according to the syslog last night the control script initiated a shutdown at 3.38 a.m. However the Pi kept running past the shutdown command somehow as can be seen from the syslog until at 4.17 a.m. almost an hour later it 'succumbed'. Of course during those 50 mintes the control script was not running any longer and no entries were made by it in the syslog.

The UPS f/w OTOH has no way of writing to the syslog, so I remain the dark how it judged the situation. The batteries must have been going down much past 3200 mV until the Pi stopped at 4:17 after the Pi had been going about its business for almost another hour as if nothing was the matter. Renewing the HA token and other normal things.

The UPS f/w hadn't cut the power at 3200 mV as it had done in my earlier tests, because in the morning I found them having only 2,5 V or lower. Much below the specified 2,75 V for these cells.

When I reconnected AC in the morning as intended, the Pi didn't start. It just kept making attempts without any result flashing its red and green leds. No HDMI output. Eventually I had to take out the batteries to find them dangerously empty and recharge them in a separate Nitecore UM-2 charger to some safer level.

No real clue as to why the UPS didn't just cut the power to the Pi as it should after the 60 seconds written to countdown timer register 0x18 by the control script before the shutdown command, nor why the UPS f/w obviously didn't observe the protection voltage of 3200 mV as it did in earlier tests when no control script was running.

Currently this UPS/Pi is running again and batteries are being charged by the UPS. I set the protection voltage higher than before, to 3500 mV, and the sampling interval had gone back to 2 minutes (apparently automatically after taking out and replacing the batteries).

It was scary to have the batteries so mistreated. They weren't hot when I took them out, but must have taken a hit.

ArjenR49 commented 3 years ago

My bad, as they say .... it was at least partially myself to blame ... Sorry for throwing doubt on the UPS in this respect.

I use Frtz13's script, but have made some changes to it and therefore I prefer to merge a new script version by Frtz13 with my version of it by using the Kompare program on my laptop. One could wait for something to go wrong there ...

The script as I had it since Frtz13's last - sweeping - changes crashed just when it needs to do the shutdown, because of a name change. This all is not very important to others. It was easy to correct after I had set the protection voltage high to gain time and restarted the script after it had crashed and not finished properly, which I didn't realize at the time. Running it in Thonny revealed the error.

Anyway .. in the event reported above I did find the batteries in the morning with very low voltage below 3 V. The control script had missed the shutdown, because it crashed and therefore the countdown timer 0x18 and the back-on-AC 0x19 weren't set. The UPS continued to power the Pi and then somehow missed its own checkpoint voltage (fully discharged) from 0x0F-0x10 set at 3200mV, or the batteries drained very quickly and steeply below the 3200mV in the attempts to start the Pi up. So ... better be careful when editing scripts containing code parts that are only rarely executed, where errors go undetected .... also maybe not go very low in the fully discharged department (which is somehow learned by the f/w from the protection voltage through discharge cycles) ... After all, a UPS 's main goal is to safely shut down the load when there is AC failure and start up again after AC comes back. No need to keep the load running without AC for hours, is there? That is a different scenario, aka mobile computing.