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

i2cset shutdown doesn't work if on AC #55

Closed b4dpxl closed 7 months ago

b4dpxl commented 3 years ago

I created a shutdown script to power off the UPS if the Pi is powered off:

/lib/systemd/system-shutdown/ups-poweroff:

#! /bin/bash

if [ "x$1" == "xpoweroff" ] || [ "x$1" == "xhalt" ] ; then
    # power off the UPS in 5 seconds
    /usr/sbin/i2cset -y 1 0x17 24 5
fi

This works fine if the UPS is on battery, but if the UPS is on AC power if doesn't work. This can also be seen by running i2cset -y 1 0x17 24 60 and observing watch -n 1 i2cget -y 1 0x17 24; when on battery the value decreases, but not when on AC. I'm running the latest firmware.

Also, if you use the button to shut off the Pi, if "back-to-ac" is enabled, the Pi turns back on after a few seconds.

nickfox-taterli commented 3 years ago

sw V8 after the repair of this problem, when you enter the shutdown command, he will first shut down, and then determine whether there is AC power, if so, will be turned on, if you want to completely shut down no longer on, you need to shut down the BACK-TO-AC.

sfatula commented 2 years ago

So, is there no way to actually power off the UPS when on AC? I set register 25,26 to 0, and 24 to 10 at shutdown time via /lib/systemd/system-shutdown script. While the machine does not reboot, I notice power is still supplied to attached devices such as USB boot drive. The display (tower case) still has power. The Pi network port lights are still on. etc.

Is there no way to turn off the power supplied by the UPS entirely when AC still exists? I want an actual power off .

galtobellojr commented 2 years ago

There was a discussion here regarding the USB 5V remaining active when unit is "powered off", and another noted that batteries are completely drained when powered off and disconnected from AC (in my experience, a week or two does it).

I've not looked into it lately, but my conclusion has been that if the USB port indeed remains live, then the battery exhaustion is explained (and, truly, expected).

This disappointed my hope to have a Portable Pi on the shelf that could be booted and remain running even while charging, much like the portability/rechargeability of one's cellphone. I've added tool-less knurled screws to the battery cover, as the batteries shouldn't stay in the unit when stored. Minor aggravation in my use case, not a total loss.

Just cleared my desk for the winter, and plan to see what happens when I connect mains power to that drained unit. I have a fireproof bag handy...

I don't have the thread IDs handy, so hope what's here helps you.

-gus

On Mon, Nov 21, 2022, 17:48 Steve Fatula @.***> wrote:

So, is there no way to actually power off the UPS when on AC? I set register 25,26 to 0, and 24 to 10, and, while machine does not reboot, I notice power is still supplied to attached devices such as USB boot drive.

Is there no way to turn off the power supplied by the UPS entirely when AC still exists?

— Reply to this email directly, view it on GitHub https://github.com/geeekpi/upsplus/issues/55#issuecomment-1322756981, or unsubscribe https://github.com/notifications/unsubscribe-auth/AU37VSIBNK3CSIBV2OZBUQTWJP325ANCNFSM5AQARAPA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

sfatula commented 2 years ago

I'm not using the code here, just my own version of it heavily modified. When I tested with no power supply, the UPS does shut off, and goes dark. It just won't do that with a supply hooked up, say I want to shut it down while out of town. I can't really.