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

What if upsPlus.py consistently fails to run #31

Closed ArjenR49 closed 3 years ago

ArjenR49 commented 3 years ago

or isn't found? Essentially my question is, what will the f/w do, if there is no control program and external power fails?

Will the UPS eventually stop draining the batteries at a voltage still safe for the batteries? I'm just wondering ...

hellresistor commented 3 years ago

i think have 'discovered' that last night. or that, or some bad configuration on raspi-blacklist.conf file. On the morning got my rpi OFF and batteries empty. seems not charging o0 Try click on power button .. ok turn on .. but low batteries.. and powers off ups and rpi. Now have detach the ups. and put it on recharge. and wait to full charge ...

Will revert back the raspi-blacklist.conf, tomorrow can give you some answer what happened :o

ArjenR49 commented 3 years ago

Well, the question is how empty? Below 2,5 V? Or did you mean the ups did its job on its own and switched power to the pi off to protect the battery?

Did you mean that I2C was disabled on the Pi?

I had to Google raspi-blacklist.conf and it was suggested raspberry os doesn't have a blacklist like that. I am only familiar with raspi-config.

Arjen (On The Road)

Op ma 17 mei 2021 20:47 schreef hellrezistor @.***>:

i think have discovered that tonight. or that, or some bad configuration on raspi-blacklist.conf file. On the morning got my rpi OFF and batteries empty. :o

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/geeekpi/upsplus/issues/31#issuecomment-842513943, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANCBKNSEJIDGUQPNZIRXVUDTOFJCHANCNFSM45AFNP4A .

frtz13 commented 3 years ago

according to a comment in issue #21, the firmware will shut down the output voltage of the UPS when battery voltage goes below the "protection voltage" (ups registers at address 0x11 / 0x12)

hellresistor commented 3 years ago

Well, the question is how empty? Below 2,5 V? Or did you mean the ups did its job on its own and switched power to the pi off to protect the battery? Did you mean that I2C was disabled on the Pi? I had to Google raspi-blacklist.conf and it was suggested raspberry os doesn't have a blacklist like that. I am only familiar with raspi-config. Arjen (On The Road) Op ma 17 mei 2021 20:47 schreef hellrezistor @.***>: i think have discovered that tonight. or that, or some bad configuration on raspi-blacklist.conf file. On the morning got my rpi OFF and batteries empty. :o — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#31 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANCBKNSEJIDGUQPNZIRXVUDTOFJCHANCNFSM45AFNP4A .

Seems working and show charging leds now 1 led fix 2nd led blink 23:23

------------------------------------------------------------
------Current information of the detected Raspberry Pi------
------------------------------------------------------------
Raspberry Pi Supply Voltage: 4.908 V
Raspberry Pi Current Current Consumption: 1135.071 mA
Raspberry Pi Current Power Consumption: 5571.068 mW
------------------------------------------------------------
-------------------Batteries information-------------------
------------------------------------------------------------
Voltage of Batteries: 3.764 V
Battery Current (Charging) Rate: 4167.805 mA
Current Battery Power Supplement: 15726.829 mW
Successfully set the protection voltage to: 3700 mV
------------------------------------------------------------
Currently charging via Type C Port.

1minutes later

------------------------------------------------------------
------Current information of the detected Raspberry Pi------
------------------------------------------------------------
Raspberry Pi Supply Voltage: 4.908 V
Raspberry Pi Current Current Consumption: 1131.034 mA
Raspberry Pi Current Power Consumption: 5793.103 mW
------------------------------------------------------------
-------------------Batteries information-------------------
------------------------------------------------------------
Voltage of Batteries: 3.784 V
Battery Current (Charging) Rate: 4203.902 mA
Current Battery Power Supplement: 15887.805 mW
Successfully set the protection voltage to: 3700 mV
------------------------------------------------------------
Currently charging via Type C Port.

+1minutes later

------------------------------------------------------------
------Current information of the detected Raspberry Pi------
------------------------------------------------------------
Raspberry Pi Supply Voltage: 4.912 V
Raspberry Pi Current Current Consumption: 1075.862 mA
Raspberry Pi Current Power Consumption: 5281.749 mW
------------------------------------------------------------
-------------------Batteries information-------------------
------------------------------------------------------------
Voltage of Batteries: 3.784 V
Battery Current (Charging) Rate: 4129.756 mA
Current Battery Power Supplement: 15536.585 mW
Successfully set the protection voltage to: 3700 mV
------------------------------------------------------------
Currently charging via Type C Port.

just cannot understand... batteries are full. but ups says "no". Well. will stay working to tomorrow. hope not stop ;)

PS: i am using rpi4 4GB + upsplus + raspios lite arm64 + homeassistant platform.

ArjenR49 commented 3 years ago

Why did you install the software again? If an original script has changed, isn't it easier to just download the newer version?

I rewrote the scripts because I found the output formatting terrible. Values accurate to the mV, mA and mW are not credible, let alone decimal fractions of those units.

You wrote you have 4 batteries. Did you make your own expansion board connecting to the 2 groups if 4 pins?

Arjen (On The Road)

Op di 18 mei 2021 01:29 schreef hellrezistor @.***>:

Well, the question is how empty? Below 2,5 V? Or did you mean the ups did its job on its own and switched power to the pi off to protect the battery? Did you mean that I2C was disabled on the Pi? I had to Google raspi-blacklist.conf and it was suggested raspberry os doesn't have a blacklist like that. I am only familiar with raspi-config. Arjen (On The Road) Op ma 17 mei 2021 20:47 schreef hellrezistor @.***>: … <#m-7383259235678430471> i think have discovered that tonight. or that, or some bad configuration on raspi-blacklist.conf file. On the morning got my rpi OFF and batteries empty. :o — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#31 (comment) https://github.com/geeekpi/upsplus/issues/31#issuecomment-842513943>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANCBKNSEJIDGUQPNZIRXVUDTOFJCHANCNFSM45AFNP4A .

  • have reverted-back raspi-blacklist.conf file.
  • batteries (4x) with 4.2v (3.7v) fullcharged.
  • Click power button (NO power cable connect), Ups on and detecting battery low (1 led blink), raspberry and OS run.
  • Re-run the upsplus.git repository, execute uninstall.sh and then install.sh
  • Fast/drastic power off of rpi and ups power
  • Connect power cable. UPS/Rpi power on auto. and wait until reach 2nd led blinking (on 1st try will happens error, because script detect low battery and send the power off)
  • Execute curl -Lso- https://git.io/JLygb | bash

Seems working and show charging leds now 1 led fix 2nd led blink 23:23


------Current information of the detected Raspberry Pi------


Raspberry Pi Supply Voltage: 4.908 V

Raspberry Pi Current Current Consumption: 1135.071 mA

Raspberry Pi Current Power Consumption: 5571.068 mW


-------------------Batteries information-------------------


Voltage of Batteries: 3.764 V

Battery Current (Charging) Rate: 4167.805 mA

Current Battery Power Supplement: 15726.829 mW

Successfully set the protection voltage to: 3700 mV


Currently charging via Type C Port.

1minutes later


------Current information of the detected Raspberry Pi------


Raspberry Pi Supply Voltage: 4.908 V

Raspberry Pi Current Current Consumption: 1131.034 mA

Raspberry Pi Current Power Consumption: 5793.103 mW


-------------------Batteries information-------------------


Voltage of Batteries: 3.784 V

Battery Current (Charging) Rate: 4203.902 mA

Current Battery Power Supplement: 15887.805 mW

Successfully set the protection voltage to: 3700 mV


Currently charging via Type C Port.

+1minutes later


------Current information of the detected Raspberry Pi------


Raspberry Pi Supply Voltage: 4.912 V

Raspberry Pi Current Current Consumption: 1075.862 mA

Raspberry Pi Current Power Consumption: 5281.749 mW


-------------------Batteries information-------------------


Voltage of Batteries: 3.784 V

Battery Current (Charging) Rate: 4129.756 mA

Current Battery Power Supplement: 15536.585 mW

Successfully set the protection voltage to: 3700 mV


Currently charging via Type C Port.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/geeekpi/upsplus/issues/31#issuecomment-842683030, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANCBKNTXQEIPEBWOY4D6H4DTOGKFPANCNFSM45AFNP4A .

hellresistor commented 3 years ago

Why did you install the software again? If an original script has changed, isn't it easier to just download the newer version?

To test with original configs, because i have changed the "SAMPLE_TIME" and "PROTECT_VOLT" variables, too.

I rewrote the scripts because I found the output formatting terrible. Values accurate to the mV, mA and mW are not credible, let alone decimal fractions of those units.

I Will try your script tomorrow

You wrote you have 4 batteries. Did you make your own expansion board connecting to the 2 groups if 4 pins?

NONONO!!!!!! i use 2 and have other to for replacement

ArjenR49 commented 3 years ago

With the watchdog (0x18 being set to 180 in upsPlus every time it runs), and all the exception handling that I can throw at it, it still happens rather often that 0x18 is NOT updated to 180 by upsPlus.py. At the moment I have taken out most time.sleep(). There is something very strange to me going on with that SMBus writing. Something I can't find. And so, every morning early I find the Pi stopped. In the UPS_event.log, I see regular cases where my upsPlus.py reports 0x18=120 ... (first it really hard tries to update to 180 .... and then a few lines of code later the script reads 120 from that register .... it should always be either 180 or 179 .... and then when upsPlus is done, the f/w counts down to 120 .... until 0x18 gets reset to 180 by the script running again one minute later.

Next I'll take out the watchdog .... have the upsPLus.py set 0x18 to 0. And test again ... And add time.sleep(0.25) or so back in in those places where something bad goes on.

I'm also thinking of making a short version of upsPlus.py with no other output than timestamp and 0x18 content. That way I'll have a log that's short enough to post ...

Also I found that not updating 0x18 correctly is apparently not the reason for PowerCycle.py to fail to restart the Pi. In v.7 it SHOULD restart the Pi ca. 10 minutes after starting the script (which sets 0x18-0x1A and then shuts down the Pi; the UPS cuts power and then 10 min. later it poweers the Pi on again .... most of the time .... sometimes it fails to start up the Pi ... in v.5 it wouldn't take 10 minutes, just 5 seconds. They changed it .... probably changed something radical in the f/w ...

yoyojacky commented 3 years ago

With the watchdog (0x18 being set to 180 in upsPlus every time it runs), and all the exception handling that I can throw at it, it still happens rather often that 0x18 is NOT updated to 180 by upsPlus.py. At the moment I have taken out most time.sleep(). There is something very strange to me going on with that SMBus writing. Something I can't find. And so, every morning early I find the Pi stopped. In the UPS_event.log, I see regular cases where my upsPlus.py reports 0x18=120 ... (first it really hard tries to update to 180 .... and then a few lines of code later the script reads 120 from that register .... it should always be either 180 or 179 .... and then when upsPlus is done, the f/w counts down to 120 .... until 0x18 gets reset to 180 by the script running again one minute later.

Next I'll take out the watchdog .... have the upsPLus.py set 0x18 to 0. And test again ... And add time.sleep(0.25) or so back in in those places where something bad goes on.

I'm also thinking of making a short version of upsPlus.py with no other output than timestamp and 0x18 content. That way I'll have a log that's short enough to post ...

Also I found that not updating 0x18 correctly is apparently not the reason for PowerCycle.py to fail to restart the Pi. In v.7 it SHOULD restart the Pi ca. 10 minutes after starting the script (which sets 0x18-0x1A and then shuts down the Pi; the UPS cuts power and then 10 min. later it poweers the Pi on again .... most of the time .... sometimes it fails to start up the Pi ... in v.5 it wouldn't take 10 minutes, just 5 seconds. They changed it .... probably changed something radical in the f/w ...

hi ArgenR49, you do not need to always set 0x18 register , you can comment it out , it is Shutdown Countdown setting , it will start countdown once you set it to a number in range 10 ~255 , for example, it will told ups to shutdown power after 240 seconds. i2cset -y 1 0x17 24 20 it means starting countdown in 20 seconds. why i put 24 after 0x17? 0x18 | Shutdown Countdown | 0(False)/10 - 255 | Bool/Sec beacuse 0x18 in binary is 00011000, decimal number is : 24 and you can modify your upsPlus.py file to fit for your needs, it is a demo code for you.