Git Product home page Git Product logo

geeekpi / upsplus Goto Github PK

View Code? Open in Web Editor NEW
68.0 14.0 25.0 64 KB

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.

Home Page: https://wiki.52pi.com/index.php?title=UPS_Plus_SKU:_EP-0136

License: MIT License

Shell 40.33% Python 59.67%

upsplus's Introduction

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.

How to use

  • Download Repository and execute:
cd ~
curl -Lso- https://git.io/JLygb

When encountering low battery, it will automatically shut down and turn off the UPS and it will restart when AC power comes.

How to upgrade firmware of UPS.

  • Upgrade firmware will be via OTA style, OTA means over the air, it allows you update or upgrade firmware via internet.
    1. Make sure Raspberry Pi can access internet.
    1. Download Repository from GitHub.
cd ~
git clone https://github.com/geeekpi/upsplus.git
cd upsplus/
python3 OTA_firmware_upgrade.py

When upgrade process is finished, it will shutdown your Raspberry Pi automatically, and you need to disconnect the charger and remove all batteries from UPS and then insert the batteries again, then press the power button to turn on the UPS. *** NOTE: Do not assemble UPS with Raspberry Pi with Batteries in it ***

Battery List.

  • A list of Batteries used by UPSPlus users community.
Brand Model Volt mAmp SAMPLE_TIME Testing Time
DoublePow ICR18650 3.7 2600 3 +180days
GTL EvreFire ICR18650 3.7 9900 3 X
XTAR ICR18650 3.7 2600 3 X

Don't forget replace PROTECT_VOLT variable value, from Battery Volt value. Example: Battery 3.6V = 3600

FAQ

  • Q: Why does the battery light go off sometime and lights up in a while?
  • A: This is because the power chip performs battery re-sampling, and the purpose is that the data of inferior batteries is inaccurate during the sampling process.
  • Q: Why is the power cut off every once in a while?
  • A: Please check the battery charging current, the data discharge direction or the charging direction. If the load is too large, the charging may not be enough, which will cause this problem.
  • Q: What kind of wall charger should I use?
  • A: If the load is normal, it is recommended to use an ordinary 5V@2A charging head. If you need to carry a slightly higher load, it is recommended to use a fast charging source. We support FCP, AFC, SFCP protocols Fast charging source.
  • Q: Can I directly input 9V and 12V to the USB port?
  • A: No, if you must do this, you must remove the DP, DM and other related detection pins, and ensure that the power supply is stable.
  • Q: I heard howling, why is this?
  • A: Because of the no-load protection mechanism, the howling will disappear after the load is installed.

upsplus's People

Contributors

deharro avatar drtywheels avatar dulus0 avatar hellresistor avatar leandroalbero avatar nickfox-taterli avatar sreknob avatar yoyojacky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

upsplus's Issues

Persistent SMBus write/read problems on countdown registers ... Please run my test and report back

Because my UPS control suffers from persistent errors concerning the power control/timer registers no matter how I try to add exception handling, I made the short script below to get a better picture.
I run it with no other scripts else concerning the UPS, but I still get wrong results from writing and then reading back the same register even with time.sleep(0.5) before and after.
The register I test is one that it should be possible to write to again and again acoording to GeeekPi.

I am at my wits end with these errors, really. If you can, stop upsPlus.py in cron and run this script on your UPS/Pi and report your results.

This is a sample output from the script below run in Thonny:

%Run CatchExceptions3.py
OK 0 - 180
OK 0 - 0
OK 1 - 180
OK 1 - 0
OK 2 - 180
OK 2 - 0
read != write 3 - 0 NOT in (180,179)
OK 3 - 0
OK 4 - 180
read != write 4 - 179 != 0
OK 5 - 179
OK 5 - 0
OK 6 - 179
OK 6 - 0

The script:

#!/usr/bin/python3
# -*- coding: utf-8 -*-

# ar - 18-05-2021

# import os
import time
# import smbus2
from smbus2 import SMBus

# Define I2C bus
DEVICE_BUS = 1

# Define device I2C slave address.
DEVICE_ADDR = 0x17

RA = 0x18

def settle():
    time.sleep(0.5)

i = 0
while True:
    try:
        settle()
        with SMBus(DEVICE_BUS) as pbus:
            pbus.write_byte_data(DEVICE_ADDR, RA, 180)
        settle()
        with SMBus(DEVICE_BUS) as gbus:
            byte = gbus.read_byte_data(DEVICE_ADDR, RA)
        settle()
        if (byte in (180,179)):
            pass
            print('OK            ', i, ' - ', byte)
        else:
            print('read != write ', i, ' - ', byte, "NOT in (180,179)")
        with SMBus(DEVICE_BUS) as pbus:
            pbus.write_byte_data(DEVICE_ADDR, RA, 0)
        settle()
        with SMBus(DEVICE_BUS) as gbus:
            byte = gbus.read_byte_data(DEVICE_ADDR, RA)
        settle()
        if (byte == 0):
            pass
            print('OK            ', i, ' - ', byte)
        else:
            print('read != write ', i, ' - ', byte, "!= 0")
        time.sleep(1)
        i += 1
    except TimeoutError as e:
        print(i, ' - ', byte, ' - ', e)
        settle()
    except KeyboardInterrupt:
        break
    except:
        pass


# EOF

Battery voltage never above 3.8V

New customer here.
I notice that the battery never charges above 3.8V and the 4th led always blinks.
Is that normal?
Report from upsPlus.py

------------------------------------------------------------
------Current information of the detected Raspberry Pi------
------------------------------------------------------------
Raspberry Pi Supply Voltage: 4.980 V
Raspberry Pi Current Current Consumption: 514.382 mA
Raspberry Pi Current Power Consumption: 2479.394 mW
------------------------------------------------------------
-------------------Batteries information-------------------
------------------------------------------------------------
Voltage of Batteries: 3.820 V
Battery Current (Charging) Rate: 86.098 mA
Current Battery Power Supplement: 336.585 mW
Successfully set the protection voltage to: 3700 mV
------------------------------------------------------------
Currently charging via Micro USB Port.

Using a 5V 3A Raspberry certified charger.
I am using firmware v7. Downgraded from v8 because of instability problems with that version.

battery is never reaching FULL status

I attached the UPS Plus V5 to a Raspberry 3B+.
My batteries have a inbuild security chip (preventing the battery from beeing depleted too deep).
The power supply (PS) is a genuine Raspberry 4 PS delivering 3 A@ 5.1 V.

After many hours running from the PS, the fourth LED of the UPS is still blinking and the batteries are charged @~40 mA continuously.
Reading the registers for "Full Voltage", Protection Voltage" and "Empty Voltage" several times in series, I realized, that the "Full Voltage" register is always changing to higher values (starting with around 4000, going up to 4289).
Those higher values can never be reached by the battery, the battery voltage is around 4208, which is a sane value for a Lipo battery.

I expected, that after max 3..4 hours the batteries are judged full and from then on the PS should only supply the RPi.

I tried to lower the register for "Full Voltage" to 4200, knowing that this value will be reached by the battery, but the controller of the UPS changes this value permanently.

Is this behavior on purpose or is it a bug?
Thanks!

Harry

Firmware v.9 available since ???, but not announced in GitHub docs.

Version 9 seems to be performing way better than version 8, but don't know what improvements or bug solving to check for. The OTA upgrade works a treat.

As a test I changed the 'protection voltage' from my usual value 3200 mV to 3700 mV, which involves writing to i2c bus registers. After upgrading from v.7 to v.8 that had become impossible at least on my UPS+, but with version 9, it was again successful.

I don't normally run Geeekpi's scripts for UPS operation, but use frtz13's very smart scripts instead (big thanks to frtz13!). Since I finally found myself in a position to add the hardware required for PWM control of the ICE Tower fan (fan 'with the fancy lights' by Geeekpi; 2-wire, no PWM), I could enable PWM control in frtz13's script. I chose GPIO18, hardware PWM, for the control (to base of transistor).
The default settings of the PI control algorithm seem to work well enough with the ICE Tower. It has a very large mass compared to the CPU and therefore a large delay, but the PI control looks like it's doing fine. The control hardware is very simple: a BJT with grounded emitter, a series base resistor of 1 kOhm, and a Schottky flywheel diode, which is rumoured to come already included in most brushless fans, so perhaps superfluous. Even with a stress test running all 4 CPU's at over 90% the ICE Tower keeps the CPU at ca. 55 degrees Celsius (as set in the INI file) on a duty cycle of only about 50% (35% ... 70%).
The same PI control loop didn't do too well on a different PI4 with only heatsinks (and a PoE). In this case the fan was not provided by GeeekPi, but by Noctua (not a PWM model, either).

[Feature Request] UPS without battery installation

I have purchased other UPS products, such as BK325I, which does not require the installation of batteries, but he is relatively bulky, I only use it to power the Raspberry Pi, so I need a lightweight, but this product requires batteries, I tried without batteries, simply can not start.

[Firmware v.9] Protection Voltage Reset (and other parameters)

So basically for some reason the Protection voltage just resets itslef to the default 3700mV once in a minute, exactly at 01 second of every minute.

Also what's the point in setting Protection voltage same as Empty voltage?

And while in case with Protection voltage I'm able to rewrite it for at least a minute, I can do nothing with Empty voltage, it accepts arguments through i2c but the result is the same – 3700mV for Empty voltage. That's why my RasPi4 turns off when I have 2 LEDs saying my UPS is only half-way empty, lol

And the same goes to the Sampling period btw – unable to change it.

0005f1fbb239ed770235396bf49f30fe.mp4

charging interface status not correctly reported

today I ran into the following problem: reading i2c bus about the current charging interface status does not work.
Problems in this situation:
Full-featured-demo-code.py reported 5151mV on Type-C USB, regardless of Type-C USB being connected to charger or not.
Full-featured-demo-code.py reported 9mV on Micro-USB, connected to a charger or not.
in this situation, battery charge and discharge worked normally and could be observed via the INA sensors and the LEDs.
once Rasberry-Pi was shut down and the power supply disconnected: the switch did not shut off the UPS.
Taking out the batteries and putting them back in restored normal operation.

Full-featured-demo-code.py result with both micro-USB and Type-C-USB disconnected:

pi@rpi-home-ass:~/upsplus $ python3 Full-featured-demo-code.py
Raspberry Pi power supply voltage: 4.880 V
Current current consumption of Raspberry Pi: 1933.726 mA
Current power consumption of Raspberry Pi: 8787.216 mW
Batteries Voltage: 4.092 V
Battery current (discharge), rate: 2697.805 mA
Current battery power consumption: 11980.488 mW
Current processor voltage: 3290 mV
Current Raspberry Pi report voltage: 4947 mV
Current battery port report voltage: 4171 mV
Current charging interface report voltage (Type C): 5151 mV
Current charging interface report voltage (Micro USB): 9 mV
Currently charging through Type C.
Current battery temperature (estimated): 41 degC
Full battery voltage: 4285 mV
Battery empty voltage: 3700 mV
Battery protection voltage: 3700 mV
Battery remaining capacity: 99 %
Sampling period: 2 Min
Current power state: normal
No shutdown countdown!
Automatically turn on when there is external power supply!
No restart countdown!
Accumulated running time: 813992 sec
Accumulated charged time: 817347 sec
This running time: 323490 sec
Version number: 4
Serial Number is:(…)

scheduled power cycling using a script

I use the script below for a scheduled power cycle of the Pi attached to the UPS.
I run it by cron every 15 minutes to stress test the UPS (in as far as power cycling)
It is never running at the same time as upsPlus.py, the control script, because I use flock file locking in cron. If scheduled, it runs after upsPlus.py, which runs every minute.

GOOD: Mostly the script will do exactly as intended, which is to shut the Pi down, and next, after the designated time (75 sec) allowing the Pi to perform the shut down in an orderly manner, cut the power to the Pi, and then after 5 seconds more, power the Pi on again -> a full power cycle.

PROBLEM: Every now and then, usually when I am not looking, the UPS FAILS to cut the power to the Pi. The Pi is then just sitting there waiting for me to press the button (twice) to get it going again.

My intention, of course, is to be able to power cycle the Pi at an appropriate time, say one per 24 h, to safeguard against software that performs poorly in some way.

The f/w version is 5 at the moment. It would be nice to be able to see somewhere what the current version is, BTW.

PowerCycle.py:

#!/usr/bin/python3
# -*- coding: utf-8 -*-

# adapted from scripts provided at GitHub: Geeekpi/upsplus by nickfox-taterli
# ar - 13-05-2021

# ''' Halt the Pi, power down, then power up Pi (= perform power cycle) '''

import os
import time
from smbus2 import SMBus 

# Define I2C bus
DEVICE_BUS = 1

# Define device I2C slave address.
DEVICE_ADDR = 0x17

# Essential UPS I2C register default values
# (name format: Operation Mode Register Address)
# for shut down & power off state
OMR0x18 = 0   # seconds, power off delay
OMR0x19 = 0   # boolean, automatic restart or not
OMR0x1A = 75  # seconds, power on delay

# Write byte to specified I2C register address
def putByte(RA, byte):
    while True:
        try:
            with SMBus(DEVICE_BUS) as bus:
                bus.write_byte_data(DEVICE_ADDR, RA, byte)
                break
        except TimeoutError:
            time.sleep(0.1)

print("*"*62)
print(("*** {:^54s} ***").
      format("Make the UPS sync & shut down Pi in an orderly manner"))
print(("*** {:^54s} ***").format("without delay & turn power off after "
      + str(OMR0x1A)+" seconds."))
print(("*** {:^54s} ***").
      format("Five seconds later the UPS will power up the Pi again."))
print("*"*62)
print()
print()

# Disable/enable automatic restart on return of external power.
#   Enable: write 1 to register 0x19
#   Disable: write 0 to register 0x19
putByte(0x19, OMR0x19)
time.sleep(2)

# For power cycle operation only 'power up' countdown (0x1A) must be set.
# UPS will cut power to the Pi 5 seconds before the end of the power up
# countdown, allowing the Pi to sync & halt in an orderly manner,
# and then turn power to the Pi on again at 0 seconds.
putByte(0x1A, OMR0x1A)
time.sleep(2)

# Halt the Pi without delay.
os.system("sudo shutdown now")

# Script continues executing, indefinitely as it were (& keeping the lock)
# until it is eventually killed by the Pi shutting down.
while True:
    time.sleep(10)

# Control is now left to the UPS' F/W and MCU ...
# EOF

failing execute install.sh

Heya.

I am trying the UPS EP-0136 on a RPI 4B 4GB and getting problem executing install script from this repository.
OS System Its Last Raspberry OS With Desktop (2021-03-04-raspios-buster-armhf)

pi@raspberrypi:~/upsplus $ bash install.sh 
[info] Welcome to 52Pi Technology UPS Plus auto-install Program!.
[info] More information please visit here:.
[info] -----------------------------------------------------.
[info] https://wiki.52pi.com/index.php/UPS_Plus_SKU:_EP-0136.
[info] -----------------------------------------------------.
[info] Start the configuration environment check....
[ ok ] Network status is ok....
[info] Start the software check....
[ ok ] git has been installed..
[info] Installing pi-ina219 library....
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pi-ina219
  Downloading https://files.pythonhosted.org/packages/fe/c9/5d9adad5393ad93d4b804324305e3505bc28becfe831ea3dc30dfa9825c0/pi_ina219-1.4.0-py2.py3-none-any.whl
Collecting mock (from pi-ina219)
  Downloading https://files.pythonhosted.org/packages/5c/03/b7e605db4a57c0f6fba744b11ef3ddf4ddebcada35022927a2b5fc623fdf/mock-4.0.3-py3-none-any.whl
Collecting Adafruit-GPIO (from pi-ina219)
  Downloading https://www.piwheels.org/simple/adafruit-gpio/Adafruit_GPIO-1.0.3-py3-none-any.whl
Collecting adafruit-pureio (from Adafruit-GPIO->pi-ina219)
  Downloading https://www.piwheels.org/simple/adafruit-pureio/Adafruit_PureIO-1.1.8-py3-none-any.whl
Requirement already satisfied: spidev in /usr/lib/python3/dist-packages (from Adafruit-GPIO->pi-ina219) (3.4)
Installing collected packages: mock, adafruit-pureio, Adafruit-GPIO, pi-ina219
Successfully installed Adafruit-GPIO-1.0.3 adafruit-pureio-1.1.8 mock-4.0.3 pi-ina219-1.4.0
[ ok ] pi-ina219 Installation successful..
[info] Installing smbus2 library....
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting smbus2
  Downloading https://files.pythonhosted.org/packages/c8/bf/62ef029fb7077fc87c3539f7365859bccc6cedb2bb20796b737b788c8d09/smbus2-0.4.1-py2.py3-none-any.whl
Installing collected packages: smbus2
Successfully installed smbus2-0.4.1
[ ok ] smbus2 Installation successful..
[info] create /home/pi/bin directory....
[info] Create python3 script in location: /home/pi/bin/upsPlus.py Successful.
[ ok ] Create UPS Plus IoT customer service python script successful.
[info] Create crontab list for pi user..
cp: imposs\u00edvel analisar '/var/spool/cron/crontabs/pi': No such file or directory
* * * * * /usr/bin/python3 /home/pi/bin/upsPlus.py
* * * * * /usr/bin/python3 /home/pi/bin/upsPlus_iot.py
[info] crontab has been created successful!.
Traceback (most recent call last):
  File "/home/pi/bin/upsPlus.py", line 21, in <module>
    ina = INA219(0.00725, address=0x40)
  File "/home/pi/.local/lib/python3.7/site-packages/ina219.py", line 116, in __init__
    self._i2c = I2C.get_i2c_device(address=address, busnum=busnum)
  File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_GPIO/I2C.py", line 64, in get_i2c_device
    return Device(address, busnum, i2c_interface, **kwargs)
  File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_GPIO/I2C.py", line 97, in __init__
    self._bus = Adafruit_PureIO.smbus.SMBus(busnum)
  File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_PureIO/smbus.py", line 125, in __init__
    self.open(bus)
  File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_PureIO/smbus.py", line 150, in open
    self._device = open("/dev/i2c-{0}".format(bus), "r+b", buffering=0)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'
[FAIL] UPS Plus Installation is Incomplete! ... failed!
[info] Please visit wiki for more information:.
[info] -----------------------------------------------------.
[info] https://wiki.52pi.com/index.php/UPS_Plus_SKU:_EP-0136.
[info] -----------------------------------------------------.

I will try one more time.

cut&paste errors in upsPlus.py

The following lines (see "<<<<" below) in upsPlus.py

# Instance INA219 and getting information from it.
ina = INA219(0.00725, address=0x40)
ina.configure()
print("-"*60)
print("------Current information of the detected Raspberry Pi------")
print("-"*60)
print("Raspberry Pi Supply Voltage: %.3f V" % ina.voltage())
print("Raspberry Pi Current Current Consumption: %.3f V" % ina.current())     <<<< "V"
print("Raspberry Pi Current Power Consumption: %.3f V" % ina.current())        <<<< "V" and "ina.current"
print("-"*60)

should read as

# Instance INA219 and getting information from it.
ina = INA219(0.00725, address=0x40)
ina.configure()
print("-"*60)
print("------Current information of the detected Raspberry Pi------")
print("-"*60)
print("Raspberry Pi Supply Voltage: %.3f V" % ina.voltage())
print("Raspberry Pi Current Current Consumption: %.3f mA" % ina.current())    <<<< "mA"
print("Raspberry Pi Current Power Consumption: %.3f mW" % ina.power())       <<<< "mW" and "ina.power"
print("-"*60)

Harry

Using the RTC to schedule some event on the UPS?

In connection with another UPS product adding a RTC to the Pi, also on a UPS board, it was said that the RTC on its own can trigger one single event. I don't know what it requires, but I assume it needs to be enabled by the hardware, too. It was used on that UPS product (made by Olmatic, Germany) to schedule a boot event. I used it for making sure the Pi would always be started up at least once a day at a certain time, in case it had somehow not restarted otherwise.

Are there plans to use the RTC for scheduling something on the UPS Plus?
Does the current hardware even allow it?

Install fails due to mixed use of smbus and smbus2

pi@luke-pi:~/Documents/upsplus $ sudo ./install.sh
[info] Welcome to 52Pi Technology UPS Plus auto-install Program!.
[info] More information please visit here:.
[info] -----------------------------------------------------.
[info] https://wiki.52pi.com/index.php/UPS_Plus_SKU:_EP-0136.
[info] -----------------------------------------------------.
[info] Start the configuration environment check....
[ ok ] Network status is ok....
[info] Start the software check....
[ ok ] git has been installed..
[ ok ] pi-ina219 library has been installed.
[ ok ] smbus2 library has been installed.
[info] create /root/bin directory....
[info] Create python3 script in location: /root/bin/upsPlus.py Successful.
[ ok ] Create UPS Plus IoT customer service python script successful.
[info] Create crontab list for pi user..
* * * * * /usr/bin/python3 /root/bin/upsPlus.py
* * * * * /usr/bin/python3 /root/bin/upsPlus_iot.py
[info] crontab has been created successful!.
------------------------------------------------------------
------Current information of the detected Raspberry Pi------
------------------------------------------------------------
Raspberry Pi Supply Voltage: 5.256 V
Raspberry Pi Current Current Consumption: 1759.966 V
Raspberry Pi Current Power Consumption: 1586.207 V
------------------------------------------------------------
-------------------Batteries information-------------------
------------------------------------------------------------
Voltage of Batteries: 4.176 V
Battery Current (discharge) Rate: 26.098 mA
Current Battery Power Consumption: 14.634 mW
------------------------------------------------------------
Traceback (most recent call last):
  File "/root/bin/upsPlus.py", line 57, in <module>
    aReceiveBuf.append(bus.read_byte_data(DEVICE_ADDR, i))
  File "/usr/local/lib/python3.7/dist-packages/smbus2/smbus2.py", line 433, in read_byte_data
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error
[FAIL] UPS Plus Installation is Incomplete! ... failed!
[info] Please visit wiki for more information:.
[info] -----------------------------------------------------.
[info] https://wiki.52pi.com/index.php/UPS_Plus_SKU:_EP-0136.
[info] -----------------------------------------------------.

See PR #1 which properly references smbus2 in the repo rather than smbus.

The latest f/w version?

Trying to upgrade the f/w involves taking out 4 screws and battery manipulation.
Doing that just to see, IF there is a newer version than the one I have, is a waste of effort, although the upgrade procedure itself works just fine.

Is there a way for UPS Plus users to see what the latest f/w version is?

My UPS is on version 7 now.

Correct script code for downgrading f/w?

There's a line in the latest OTA_firmware_upgrade-py script which can be used to downgrade the f/w to an older version:
r = requests.post(UPDATE_URL, data={"UID0":UID0, "UID1":UID1, "UID2":UID2, , "ver":7})

The extra comma before the "ver" has me wondering. Is it correct?
There seems to be an empty item first and only then the "ver":7

I'd rather not blindly try to find out, which might leave the UPS in the upgrade mode.

Battery voltage reports 32V

I brought a new UPS and while everything is OK I have a strange battery voltage which always reports 32V. I didn't check this with a voltmeter but I'm positively sure that two 3.7 v battery cannot output 32V even by accident.

The output of Full-featured-demo-code.pyis:

Raspberry Pi power supply voltage: 5.004 V
Current current consumption of Raspberry Pi: 1198.654 mA
Current power consumption of Raspberry Pi: 5991.590 mW
Batteries Voltage: 32.000 V
Battery current (charging), rate: 2615.854 mA
Current battery power supplement: 83712.195 mW
Current processor voltage: 3337 mV
Current Raspberry Pi report voltage: 5032 mV
Current battery port report voltage: 3857 mV
Current charging interface report voltage (Type C): 6 mV
Current charging interface report voltage (Micro USB): 0 mV
Currently not charging.
Current battery temperature (estimated): 39 degC
Full battery voltage: 4297 mV
Battery empty voltage: 3700 mV
Battery protection voltage: 3700 mV
Battery remaining capacity: 18 %
Sampling period: 2 Min
Current power state: normal
No shutdown countdown!
Automatically turn on when there is external power supply!
No restart countdown!
Accumulated running time: 59847 sec
Accumulated charged time: 283677 sec
This running time: 3931 sec
Version number: 8
Serial Number is:private

Firmware v.8: changing sample period (interval) impossible, but changing protection voltage OK ...???

On my UPS Plus I can change the protection voltage with what is essentially a few lines from the 'full feature ....' script:

    try:
        givenPV_mV = int(sys.argv[1])
        if givenPV_mV >= PV_Mini_mV and givenPV_mV <= PV_Maxi_mV :
            bus.write_byte_data(DEVICE_ADDR, 0x11, givenPV_mV & 0xFF)
            bus.write_byte_data(DEVICE_ADDR, 0x12, (givenPV_mV >> 0o10) & 0xFF)
            print("Successfully set the protection voltage to: %d mV" % givenPV_mV)
        else:
            errMsg = "Valid protection voltage values range from {:.0f} to {:.0f} mV".format(PV_Mini_mV, PV_Maxi_mV)
            print(errMsg)
    except Exception as exc:
        print("Incorrect parameter: {}. ({})".format(sys.argv[1], str(exc)))

where givenPV_mv is the argument when executing the script.
As long as the argument in mV stays between the set limits, the new value gets written to the registers.

However, if I do the same for the sample period (argument name givenSI), every execution with an acceptable value ends in an error situation from which the f/w doesn't recover by just restarting the Pi.
The code is just like the lines above:

    try:
        givenSI = int(sys.argv[1])
        if givenSI >= SI_Min and givenSI <= SI_Max :
            bus.write_byte_data(DEVICE_ADDR, 0x15, givenSI & 0xFF)
            bus.write_byte_data(DEVICE_ADDR, 0x16, (givenSI >> 0o10) & 0xFF)
            print("Successfully set the battery sampling interval to: %d min" % givenSI)
        else:
            errMsg = "Valid sampling interval values range from {:.0f} to {:.0f} min".format(SI_Min, SI_Max)
            print(errMsg)
    except Exception as exc:
        print("Incorrect parameter: {}. ({})".format(sys.argv[1], str(exc)))

After this I can still shut the Pi down from the GUI, but I have to disconnect the power and remove the batteries to make the f/w work again.
Both scripts are based on the script setProtectionVoltage.py by frtz13. Above are just the core lines with the write_byte_data function calls which are just like the ones in the 'full feature ...' script.

I run ftrz13's control script fanShutDownUps.py on my UPS/Pi combo. It is possible by certain *.ini settings to make it shut down the Pi immediately upon disconnecting the AC power. However, since that involves writing to a few i2c registers, too, the shut down never happens because of a crash. This was also reported by frtz13 himself in another issue.

Very much looking forward to a f/w version that can handle writes properly making operation as a UPS, protecting from AC power blackouts, possible again! At the moment the UPS doesn't protect from anything.
I am not going to try out what is will do to my batteries, when the UPS doesn't shut down the Pi and it keeps running indefinitely without AC. Too risky.

LED indicator

Is it possible to disable these?
Would like to reduce the power consumption when not powered from ac.

[Feature Request] Maximum battery charge limit

Hello, lots of phone or laptop manufacturers are including optimised battery charging into their devices. What this does is halt charge at around 80% instead of holding the battery cells at 100% charge during long periods of time. This greatly reduces battery ageing.
Is it possible to do this via software on upsplus?

i2cset shutdown doesn't work if on AC

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.

Charging port voltage incorrectly reported

using firmware version 7
my UPS board has gone into a state where it no longer reports the voltage on the USB charging ports.
the reported USB-C charging port voltage stays at 4865mV regardless of a power supply connected or not.
the reported Micro-USB charging port stays at 0mV regardless of a power supply connected or not.
all other UPS functions seem normal: output power, battery charging, other measurements, LEDs.
nothing special has happened to the UPS, it was just doing its job.

NB: this charging port reporting error now has happened for the second time. it already happened a couple of days ago with firmware version 4. I did not report it at that time because I did a firmware upgrade shortly afterwards. In this situation, the only way to establish normal operation again was to take out the batteries. it was impossible to switch off the UPS using the button. To reset the UPS I had to take out the batteries with the UPS running.

Edit May 17th 7:45 UT: I keep the UPS in the "non reporting state". please tell me of any other useful information for you.

Edit May 18th 9:15 UT: I realized that also battery temperature is no longer updated, it is reported as being 44°C, with no fluctuations at all, which is not normal. As I keep battery temperature history, I found out that the UPS went into this buggy state on May 15th, 19:16 UT. My UPS reports back telemetry data to https://api.thekoziolfoundation.com. I can send you the UID of my UPS in a private message if you are interested.

$ python3 Full-featured-demo-code.py
Raspberry Pi power supply voltage: 4.888 V
Current current consumption of Raspberry Pi: 1648.276 mA
Current power consumption of Raspberry Pi: 7966.358 mW
Batteries Voltage: 4.148 V
Battery current (discharge), rate: 2120.000 mA
Current battery power consumption: 8775.610 mW
Current processor voltage: 3281 mV
Current Raspberry Pi report voltage: 4927 mV
Current battery port report voltage: 4190 mV
Current charging interface report voltage (Type C): 4865 mV
Current charging interface report voltage (Micro USB): 0 mV
Currently charging through Type C.
Current battery temperature (estimated): 44 degC
Full battery voltage: 4287 mV
Battery empty voltage: 3700 mV
Battery protection voltage: 3700 mV
Battery remaining capacity: 98 %
Sampling period: 2 Min
Current power state: normal
No shutdown countdown!
Automatically turn on when there is external power supply!
No restart countdown!
Accumulated running time: 273684 sec
Accumulated charged time: 285221 sec
This running time: 5149 sec
Version number: 7
Serial Number is:(...)

V8 Firmware overcharged Samsung 25R batteries

I'm running V8 Firmware. I left the unit plugged into the charger overnight. When I came back it luckily didn't catch fire. However both batteries, genuine Samsung 25R, are COMPLETELY dead - multimeter can't detect any appreciable voltage between the terminals. I've unplugged the charger and replaced the batteries with another fully charged set. When I ran the Full-featured-demo-code.py script it gave me:

Full battery voltage: 4914 mV

It seems the unit kept overcharging them until some internal fuse blew. I tried doing the following:

fullVoltage = 4100
self.bus.write_byte_data(DEVICE_ADDR, 13, fullVoltage & 0xFF)
self.bus.write_byte_data(DEVICE_ADDR, 14, (fullVoltage >> 8)& 0xFF)

but it doesn't seem to be able to write to that register - Full voltage is still at 4.9V

Has anyone else had a similar issue? Is it even possible to set max charging voltage? I think it should be - batteries last longer if they aren't charged to 100%, so maybe setting max charged V to 4.0V might be useful.

charging issue

when I plug in the charger the raspberry pi turns on automatically how come?

I feel it should only turn on when I push the power button how do I fix that

on debian rpi aarch64 system

Hello
I am using this image Debian 10 raspberry

# uname -a
Linux rpi4-20210210 5.10.0-0.bpo.5-arm64 #1 SMP Debian 5.10.24-1~bpo10+1 (2021-03-29) aarch64 GNU/Linux
# sudo i2cdetect -y 1
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory

I am getting this directory /boot/firmware/config.txt instead the default /boot/config.txt

The file contains:

# Switch the CPU from ARMv7 into ARMv8 (aarch64) mode
arm_64bit=1

enable_uart=1
upstream_kernel=1

### UPSPro Config Added manually ###
dtoverlay=i2c-rtc,ds1307
dtparam=i2c_arm=on
##################

kernel=vmlinuz-5.10.0-0.bpo.5-arm64
# For details on the initramfs directive, see
# https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=10532
initramfs initrd.img-5.10.0-0.bpo.5-arm64

I cannot getting info from UPS .

Executing the script, getting this :|

$ sudo python3 bin/upsPlus_iot.py
[sudo] password for ha:
Traceback (most recent call last):
  File "bin/upsPlus_iot.py", line 16, in <module>
    ina = INA219(0.00725,address=0x40)
  File "/usr/local/lib/python3.7/dist-packages/ina219.py", line 116, in __init__
    self._i2c = I2C.get_i2c_device(address=address, busnum=busnum)
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_GPIO/I2C.py", line 63, in get_i2c_device
    busnum = get_default_bus()
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_GPIO/I2C.py", line 55, in get_default_bus
    raise RuntimeError('Could not determine default I2C bus for platform.')
RuntimeError: Could not determine default I2C bus for platform.

have tried create a link with ln -s /boot/firmware/config.txt /boot/config.txt , but not work.

Maybe a ARM64 imcompatibility ?

PS: The RPI leds are off (both green/red)

Raspberry Shutdown but not shutdown

photo_2021-05-13_20-10-04
Hello
Have executed sudo shutdown now on raspberry pi to halt the rpi.

But seems after turn off rpi leds like 1 second turn red.

Tried to shutdown by UPS buton. but not happens.

Some way to force shutdown ?

Some problem on batteries or UPS?

Hello
I have a little test today. I have been used the UPS more than 48hours (with a Fast Charger).

Now I have Disconnected IT. And start get I think to much dropdown.

  $ python3 upsplusv5-battery-logger.py
['Time (s)', 'Volts (mV)', 'Power (mW)', 'Remaining %']
['84716', '4184', '5463', '99']
['84721', '4198', '4733', '99']
['84726', '4185', '5087', '99']
['84731', '4174', '4686', '78']    ===> When I Disconnect UPS From Charging.
['84736', '4193', '4646', '78']
['84741', '4175', '4673', '78']
['84747', '4200', '4663', '78']
['84752', '4193', '4750', '76']
['84757', '4179', '4646', '76']
['84762', '4190', '4717', '76']
['84767', '4190', '4626', '76']
['84772', '4166', '4669', '76']
['84778', '4169', '4690', '76']
['84783', '4159', '4801', '74']
['84788', '4188', '4851', '74']
['84793', '4175', '4851', '74']
['84798', '4174', '5362', '74']
['84803', '4169', '4885', '74']
['84809', '4180', '4717', '74']
['84814', '4184', '4690', '74']
['84819', '4159', '4690', '74']
['84824', '4166', '4888', '72']
['84829', '4169', '4861', '72']
['84834', '4174', '4834', '72']
['84840', '4172', '4824', '72']
['84845', '4171', '4653', '72']
['84850', '4146', '4619', '72']
['84855', '4167', '4646', '72']
['84860', '4175', '4626', '72']
['84865', '4177', '4636', '72']
['84870', '4167', '4653', '72']
['84876', '4174', '4653', '72']
['84881', '4177', '4669', '72']
['84886', '4134', '4669', '72']
['84891', '4155', '4646', '72']
['84896', '4146', '4619', '72']
['84901', '4158', '5120', '72']  ==> Seems stablised on this value

Keep in touch :)

Other situation I have seen. The Last Blue Led Never Stops Blink when charging (like as never reach the full charge) ( I have an eye on other issue topic ;) )

UPS not charging batteries correctly

Hello friends.
Yesterday have arrived to home and see my rpi off (with no time to check), today i have checked... the UPS are not charge the batteries correctly. Actually batteries have ~2.1V each.
I am using a 3Amp quality charger.

Maybe this issue have about the Fw7 ? or hw issue?
Or give me a recommendation of batteries brand/model ?
i have 4x new brand.. doing the same on both pairs.. I think this it is because I never get the 4 fix led on. always got the 4th blinking.

issue running the update

when i run these instructions this is my response

Method 1
NOTE: Do not power off or disconnect the network during the upgrade process. If the upgrade fails, the UPS Pro will not work normally.

Power off the Raspberry Pi.
Cut off the external charging power (MicroUSB and USB-C)
Take out all the batteries.
Press and hold the UPS Pro switch key and insert the battery into the battery compartment.
At this time, the device will be forced to enter OTA mode.
The function of the switch button will no longer be available at this time.
The Raspberry Pi will be running and please execute the following python script in the system terminal to complete the upgrade.

Download python scripts from github:
cd ~
git clone https://github.com/geeekpi/upsplus.git
cd ~/upsplus
python3 OTA_firmware_upgrade.py
The first time it runs, it may prompt that the device is not registered.If it is a legal device, just wait a few seconds and try again.

UPS Pro Will be turned off after upgrading, Please unplug the power supply, remove the batteries from UPS Pro.
Insert the batteries back to UPS Pro and then connect power supply and turn it on by press power switch.

pi@raspberrypi:~ $ cd ~
pi@raspberrypi:~ $ git clone https://github.com/geeekpi/upsplus.git
fatal: destination path 'upsplus' already exists and is not an empty directory.
pi@raspberrypi:~ $ cd upsplus/
pi@raspberrypi:~/upsplus $ python3 OTA_firmware_upgrade.py
Traceback (most recent call last):
  File "OTA_firmware_upgrade.py", line 18, in <module>
    bus = smbus2.SMBus(DEVICE_BUS)
  File "/home/pi/.local/lib/python3.7/site-packages/smbus2/smbus2.py", line 280, in __init__
    self.open(bus)
  File "/home/pi/.local/lib/python3.7/site-packages/smbus2/smbus2.py", line 310, in open
    self.fd = os.open(filepath, os.O_RDWR)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'
pi@raspberrypi:~/upsplus $ 

Pi Supply voltage cannot be read. Always 0

Input charger volatge and other charactersistics cannot be read. Second UPS that came.

Tried with RPi B+ & ZeroW with latest Raspian fully patched.
UPS updated to latest firmware.

Charger is connected, with good voltage and charging batteries.

Using code below:

import os
import time
import logging
from ina219 import INA219,DeviceRangeError

ina = INA219(0.00725, address=0x40)
ina.configure()
while True:
print("Raspberry Pi Supply Voltage: %.3f V" % ina.voltage())
print("Raspberry Pi Current Current Consumption: %.3f mA" % ina.current())
print("Raspberry Pi Current Power Consumption: %.3f mW" % ina.power())
print("Shunt voltage: %.3f mV" % ina.shunt_voltage())
time.sleep(1)

It only shows 0 values:

Raspberry Pi Supply Voltage: 0.000 V
Raspberry Pi Current Current Consumption: 0.000 mA
Raspberry Pi Current Power Consumption: 0.000 mW
Shunt voltage: 0.000 mV
Raspberry Pi Supply Voltage: 0.000 V
Raspberry Pi Current Current Consumption: 0.000 mA
Raspberry Pi Current Power Consumption: 0.000 mW
Shunt voltage: 0.000 mV
Raspberry Pi Supply Voltage: 0.000 V
Raspberry Pi Current Current Consumption: 0.000 mA
Raspberry Pi Current Power Consumption: 0.000 mW
Shunt voltage: 0.000 mV
Raspberry Pi Supply Voltage: 0.000 V
Raspberry Pi Current Current Consumption: 0.000 mA
Raspberry Pi Current Power Consumption: 0.000 mW
Shunt voltage: 0.000 mV

UPS is always shutting down when disconnected from PS

In "upsplus.py" on line 86 you compare ina.voltage() to PROTECT_VOLT.

The return value of ina.voltage() is something like "4.208".
PROTECT_VOLT is 3700.

Therefore the comparison
if ina.voltage() < (PROTECT_VOLT + 200):
will always be true and the Raspberry is always shut down when the power supply is diconnected.

Remedy:
if ((ina.voltage() * 1000) < (PROTECT_VOLT + 200)):

Harry

UPS not responding after update

I was using the ups for a long time on the version 3 and then decided to update since I saw on the github there was a newer version.

While upgrading everything went great I had a successfull message at the end and then the UPS powered off by itself.
After that, the pi would want to turn on anymore. I see the red light on the ups on and one bluelight slowly flashing (I don't have the batteries pluged in at this point).

I tried to reflash the firmware by powering the pi and the ups seperatly, but the pi cannot communicate with the ups I get a I/O error.

Traceback (most recent call last):
  File "OTA_firmware_upgrade.py", line 51, in <module>
    bus.write_byte_data(0x18, i + 1, data[i])
  File "/home/pi/.local/lib/python3.7/site-packages/smbus2/smbus2.py", line 455, in write_byte_data
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error
Traceback (most recent call last):
  File "upsplus_iot.py", line 36, in <module>
    aReceiveBuf.append(bus.read_byte_data(DEVICE_ADDR, i))
  File "/home/pi/.local/lib/python3.7/site-packages/smbus2/smbus2.py", line 433, in read_byte_data
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error

I used a voltmeter and checked the voltage between the pins that connect the raspberry pi and the ups and I get only 3V.
Any one have an Idea what I can do with that? it's a quite deceiving experience.

What if upsPlus.py consistently fails to run

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 ...

(In progress) 1st use. not get full charged.

Hello, after the 'saga' about my first UPSplus device, me @deHarro have getting problems.
I put it a side (the 1st upsplus) and start over 0.

With a New RPI4 and the 2nd UPSplus (both unboxed, never used, and get power button OK).

  • Get Full Charged Batteries first thing
  • Assembled the UPSpro on RPI4 like official instrunctions (until now should be a FW5).
  • Insert a sdcard with clean raspberryOS (previously uncommented the line dtparam=i2c_arm=on on /boot/config.txt file)
  • Insert Batteries ( UPS detect batteries but do not power ON, seems OK)
  • Insert Power Cable (UPS Start Charging, NOT start RPI, Until here, seems OK)
  • Get 3 fix blue LED and 1 Led Blink (it was been suppose full charged... not Charging... but ok.. give some time..)
  • Keep it charging like 2hours (THIS IS WHEN I NOTICED, NOT when really happens, maybe less time than 2hours). All Leds Became Off during ~ 2 seconds, than start the charging process, Like as Have Disconnect and Connect the cable (I not have touch on cacle). and keep same loop between 3~5m.
  • Never Get Fully Charged, baterries are fully charged. (with 2x new Pairs (x4) batteries)
  • If I Disconnect Power Cable. The All 4 Blue Leds get FIXED. Connect the Cable... again.. 1blink...

Waiting some feedback to can proceed with my test.

The Next Steps to do: (waiting feedback):

  • Click UPSplus power Button
  • Finish Rasberry OS config and mannually add values dtoverlay=i2c-rtc,ds1307 on /boot/config.txt file
  • Shutdown RPI
  • Remove PowerCable + Batteries (EXPECTING?!)
  • Insert Batteries + PowerCable
  • If Rpi Run Auto or need click ups power button (EXPECTED?!?) start the main test before booting, If get fully charged batteries LED indicator.
  • IF not Fix 4 LEDS. Boot Rpi again and DO the Fw Upgrade to fw7. And Re-Test again..

Under-voltage detected

sometimes I get "under voltage" warnings in my raspberry pi log.
running Raspberry Pi 4b + SSD + UPSPlus.

in syslog several events like:

20:06:52 rpi kernel: Under-voltage detected! (0x00050005)
20:07:17 rpi kernel: Voltage normalised (0x00000000)

to investigate the issue, I run a background task on the RPi which calls the INA219 sensor at address 0x40 every second.
for each one minute interval it determines the minimum output voltage and the maxium output current and sends it to the graphic.

upsOut

this seems to show that the peaks of 2.7A output current make drop the output voltage as measured by the INA219 sensor to below 4.87 V which triggers the under-voltage warnings.
is there a setting to set the output voltage a little bit higher?

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

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.

install.sh has bug

The install.sh has a bug in line 163.
here batt_voltage is a float but the line calls it as a function
if ((batt_voltage() * 1000) < (PROTECT_VOLT + 200)):

als a result the script crashes. can be fixed by removing the brackets.
also I recommend updating the static code with the current upsplus.py code

The current and power readings of the Raspberry INA219 are way too big

I am in a lengthy conversation with the hotline of GeeekPi concerning UPS stops powering the system with charger still attached, despite the fact, that the charger still delivers power.

In the beginning the staff insisted on "bad/weak batteries" and a very heavy overall power consumtion of my system.
In the path of tracking down the problem I realized, that the readings of the INA219 are more than 5 times bigger than metered with a clamp-on ammeter.
By tweaking the SHUNT_OHMS parameter in the INA instantiation and setting some other parameters in the configure call to reaonable values I managed to make the readings more or less consistent to each other.

My initialisation of the INA chip for the Raspberry is now

MAX_EXPECTED_AMPS = 2
SHUNT_OHMS = 0.007 * 5.5

# Instance INA219 and getting information from it.
ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS, address=0x40)
ina.configure(ina.RANGE_16V, ina.GAIN_2_80MV, ina.ADC_32SAMP,  ina.ADC_32SAMP)

Harry

[Firmware V.9] Battery voltage bad data after a few hours.

Hi, after being in operation for a few hours, the battery voltage reading is wrong.

2021/07/21 14:05:02
Raspberry Pi power supply voltage: 4.760 V
Current current consumption of Raspberry Pi: 2081.245 mA
Current power consumption of Raspberry Pi: 10247.267 mW
Batteries Voltage: 4.220 V
Battery current (charging), rate: 168.049 mA
Current battery power supplement: 712.195 mW
Current processor voltage: 3309 mV
Current Raspberry Pi report voltage: 5116 mV
Current battery port report voltage: 4187 mV
Current charging interface report voltage (Type C): 5417 mV
Current charging interface report voltage (Micro USB): 38 mV
Currently charging through Type C.
Current battery temperature (estimated): 48 degC
Full battery voltage: 4270 mV
Battery empty voltage: 3789 mV
Battery protection voltage: 3600 mV
Battery remaining capacity: 97 %
Sampling period: 2 Min
Current power state: normal
No shutdown countdown!
Automatically turn on when there is external power supply!
No restart countdown!
Accumulated running time: 7978 sec
Accumulated charged time: 8002 sec
This running time: 7972 sec
Version number: 9
Serial Number is: xxxxxxx-xxxxxxx-xxxxxxx

1 minute later:

2021/07/21 14:06:01
Raspberry Pi power supply voltage: 4.972 V
Current current consumption of Raspberry Pi: 2510.177 mA
Current power consumption of Raspberry Pi: 13917.578 mW
Batteries Voltage: 3.764 V
Battery current (charging), rate: 128.049 mA
Current battery power supplement: 448.780 mW
Current processor voltage: 3309 mV
Current Raspberry Pi report voltage: 5094 mV
Current battery port report voltage: 4214 mV
Current charging interface report voltage (Type C): 5391 mV
Current charging interface report voltage (Micro USB): 64 mV
Currently charging through Type C.
Current battery temperature (estimated): 48 degC
Full battery voltage: 4270 mV
Battery empty voltage: 3789 mV
Battery protection voltage: 3600 mV
Battery remaining capacity: 97 %
Sampling period: 2 Min
Current power state: normal
No shutdown countdown!
Automatically turn on when there is external power supply!
No restart countdown!
Accumulated running time: 8034 sec
Accumulated charged time: 8058 sec
This running time: 8028 sec
Version number: 9

It also happens with firmware 7 and 8.

The only way to get a good measurement again is to turn off the UPS, remove the batteries, put the batteries and turn the UPS back on.

[Firmware v. 9] i2c readings freeze after a couple of hours of operation

after a couple of hours of operation, register readings from address 0x17 freeze, and do no longer return useful values. this behaviour seems quite similar to the v.7 firmware. I did not find any release notes about the v.9 firmware. is there supposed to be any improvement?
BTW: I changed the sample period to 60 minutes. this did not seem to make any difference in the useful lifetime of the firmware.
you are getting telemetry data from this UPS, look at submission ID 3010939 etc.

ups switches back on after shutdown countdown, even when AC power is not restored

follow-up on issue #7

using firmware v. 5
after a shutdown countdown, with Back-To-AC Auto Power up enabled, the UPS switches back on, even when no AC power supply is connected.

pi@raspberrypi:~/upsplus $ python3 Full-featured-demo-code.py
Raspberry Pi power supply voltage: 4.936 V
Current current consumption of Raspberry Pi: 1184.861 mA
Current power consumption of Raspberry Pi: 5665.265 mW
Batteries Voltage: 4.064 V
Battery current (discharge), rate: 1590.000 mA
Current battery power consumption: 6473.171 mW
Current processor voltage: 3282 mV
Current Raspberry Pi report voltage: 4962 mV
Current battery port report voltage: 4042 mV
Current charging interface report voltage (Type C): 73 mV
Current charging interface report voltage (Micro USB): 0 mV
Currently not charging.
Current battery temperature (estimated): 46 degC
Full battery voltage: 4285 mV
Battery empty voltage: 3700 mV
Battery protection voltage: 3700 mV
Battery remaining capacity: 55 %
Sampling period: 2 Min
Current power state: normal
No shutdown countdown!
Automatically turn on when there is external power supply!
No restart countdown!
Accumulated running time: 7634 sec
Accumulated charged time: 7639 sec
This running time: 5964 sec
Version number: 5
Serial Number is:(...)

Not copy crontab?

Executing this:
curl -Lso- https://git.io/JLygb | bash

one line return this:
cp: impossível analisar '/var/spool/cron/crontabs/pi': No such file or directory

This line of script mention before

sudo sed -i '/upsPlus/d' /var/spool/cron/crontabs/pi 2>/dev/null
sudo cp /var/spool/cron/crontabs/pi /tmp/crontab_pi
:~# cat /var/spool/cron/crontabs/pi
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (- installed on Wed May 12 21:28:17 2021)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
* * * * * /usr/bin/python3 /root/bin/upsPlus.py
* * * * * /usr/bin/python3 /root/bin/upsPlus_iot.py
* ~# cat /tmp/crontab_pi
* * * * * /usr/bin/python3 /root/bin/upsPlus.py
* * * * * /usr/bin/python3 /root/bin/upsPlus_iot.py

but seems good o0 (I think ignore it.. )

UPS stops powering the system with charger still attached

I have a Raspberry 3 B+ with the UPSplus running firmware V4.
From time to time the UPS stops supplying the system (UPS + RPi) and the RPi is powered from the batteries from this moment on.

From here on there arise several problems.

The first problem: In the script "upsPlus.py" the case "check the battery voltage" is not reached, since the charger is still attached and delivers a voltage which is recognized. -> Remedy: Move the case one level out. This part of the script should read as

if (aReceiveBuf[8] << 8 | aReceiveBuf[7]) > 4000:
    print('-'*60)
    print('Currently charging via Type C Port.')
elif (aReceiveBuf[10] << 8 | aReceiveBuf[9])> 4000:
    print('-'*60)
    print('Currently charging via Micro USB Port.')
else:
    print('-'*60)
    print('Currently not charging.')

# Consider shutting down to save data or send notifications
if (ina.voltage() * 1000) < (PROTECT_VOLT + 200):                 # <<-- this case was situated in the else clause
    print('-'*60)
    print('The battery is going to dead! Ready to shut down!')
# It will cut off power when initialized shutdown sequence.
    bus.write_byte_data(DEVICE_ADDR, 24,240)
    os.system("sudo sync && sudo halt")
    while True:
        time.sleep(10)

The second problem: The RPi is never restarted.
The most significant problem: WHY AT ALL does the UPS stop feeding the current from the charger to the system?

I am in contact with the hotline staff for some days now on this problem and they are eager to pass information from me and the development crew to and fro, but all in all I am not satisfied with this slow communication.
To speed up the conversation, I now raise this issue.

Harry

firmware version 8: shutdown countdown does not work any more

using firmware v. 8
after starting a firmware shutdown
i2cset -y 1 0x17 24 30
the UPSPlus goes into a buggy state:

  • 5V output power is NOT switched off (red light next to pogo pins stays on, RPi is not switched off).
  • i2c bus communication is broken: i2cdetect -y 1 takes a minute or so to execute, and does not detect the devices at addresses 0x17, 0x40 and 0x45.
  • without charger connected, blue battery charge indicators will switch off eventually and stay off, regardless of charge status.
  • the UPSPlus cannot be switched off using the button.

AC power coming back during shutdown countdown

using firmware v. 4
when AC power comes back on during the shutdown countdown, I realized that the 5V supply for the raspberry pi is not switched off at the end of the countdown. so, after shutdown of the operating system, the raspberry pi will never restart automatically.
IMHO the following would be better: once a shutdown countdown starts, and we have the Back-To-AC Auto Power UP flag set, then:

  • the shutdown sequence should proceed to its end,
  • switch off the 5V-power for a certain time (a couple of seconds maybe), regardless of AC Power.
  • switch the 5V back on when AC power is restored.

otherwise, I am very happy with the product.
one more thing: would be nice to have some sort of alert for new firmware releases and release notes for these.

very good product, but there is a feature request.

I have been using this product for more than a month and it works well, there were two-times AC power outages and the system was not affected at all, but I recently tried the OTA function and I found that this function has to remove the battery in order to use it, which is a bit of a hassle and I hope it can be improved.

Another is that after the battery is full, it seems to be recharged every 5 minutes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.