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

Please make the firmware honour the fixed battery max/min voltage settings #122

Closed toruvinn closed 7 months ago

toruvinn commented 1 year ago

Originally posted in https://github.com/geeekpi/upsplus/issues/87#issuecomment-1366563587

$ upsPlus_iot.py 
{
  "PiVccVolt": 5.148,
  "PiIddAmps": 984.861227922624,
  "BatVccVolt": 4.204,
  "BatIddAmps": 80.0,
  "McuVccVolt": 3290,
  "BatPinCVolt": 4198,
  "ChargeTypeCVolt": 9081,
  "ChargeMicroVolt": 64,
  "BatTemperature": 40,
  "BatFullVolt": 4000,
  "BatEmptyVolt": 3600,
  "BatProtectVolt": 3700,
  "SampleTime": 2,
  "AutoPowerOn": 1,
  "OnlineTime": 161237,
  "FullTime": 161237,
  "OneshotTime": 161237,
  "Version": 10
}

You can see I've set:

  "BatFullVolt": 4000,
  "BatEmptyVolt": 3600,
  "BatProtectVolt": 3700,

But unfortunately the UPS seems to ignore it. Of course I've done bus.write_byte_data(DEVICE_ADDR, 42, 1):

FixedVbat register is: 1
Full Voltage register is: 4000
Empty Voltage register is: 3600

Firmware version is 10, as stated above. I would really wish to set the max voltage to some arbitrary number, to prolong the battery life (not to mention, I really want the UPS to stop constantly charging them when they are full already), probably at around 60-70% capacity, that's more than enough for my use case.

Would that be possible to make ups+ actually honour those settings, please? Additionally, what are those settings used for, currently? I feel they are completely ignored?

Thank you.

yoyojacky commented 7 months ago

The battery voltage cannot be set, it can only be collected, that is, the battery voltage is detected, and there is no way to set the battery voltage and current.

toruvinn commented 1 month ago

Does this mean that register 42/0x2A which is still listed on the wiki was a NOOP from the start? I cannot find the example scripts that also modify the charging thresholds. I of course understand that modification to any registers won't change the battery parameters, but the request was regarding the ability to change thresholds (i.e. batt voltage when UPS performs shutdown, and voltage when it stops charging the battery). Additionally documentation states that in V9:

Version V9:

  • [Bug fix] The manual voltage can not be set, please note that the manual setting threshold voltage only affects the charging logic, and does not change the parameters of the battery itself.

Which is basically what I meant above too. For me, modification of the thresholds does nothing. I would absolutely love to set the shutdown voltage a bit higher (to prevent battery from discharging below 30-40%) and max voltage (to stop charging) around 70% of the battery capacity to prevent unnecessary wear. This is what that issue was about, apologies for not being very clear.