UPS

From PlebNet Wiki
Jump to navigation Jump to search
Other languages:
English

Add a Backup Power Supply

A UPS (uninterruptible power supply) ensures that your node continues to function through minor power fluctuations and power outages.

If you don’t shut your Raspberry Pi down properly this is essentially the same as pulling the power cord out of your desktop computer every time you want to shut it down. When this happens, you risk corrupting your device’s SD card, as well as data on your hard drive.

The solution is that you plug your device into a high-output power bank. This is basically a juiced-up version of what you might use to charge your phone while camping. The battery pack gets plugged into the wall and your device gets plugged into the battery pack.

A UPS should only be relied on to provide you with enough time to safely shut down your node until your power is restored. You should not connect your router or modem to the UPS due to potential data corruption that may occur if your node is in the process of writing to the disk when a power outage occurs.

Many UPS devices have a loud audible alert that will be triggered when the power goes out.

Here are some options to consider:


Advanced UPS Setup

If you want to automate a graceful shutdown for the node once the UPS power capacity goes to a minimum level, you can connect the UPS Serial port (via USB) to the Raspberry Pi or PC and have it communicate with the UPS once configuring the UPS daemon in the Pi or you Linux setup correctly, it will initiate a graceful shutdown if the capacity hits 5%

The following steps should be run via SSH:

sudo apt-get install apcupsd
sudo nano /etc/default/apcupsd

In /etc/default/apcupsd change ‘ISCONFIGURED=no’ to ‘ISCONFIGURED=yes’

sudo nano  /etc/apcupsd/apcupsd.conf

Change the values as below, make sure the DEVICE field is empty, the default is /dev/ttyS0 and should be cleared.

UPSNAME myups
UPSCABLE usb
UPSTYPE usb
DEVICE

Note - Make sure the Restart apcupsd

sudo apcupsd restart

Check UPS

CHECK IF UPS IS RECOGNISED OR ELSE YOU WILL HAVE TO STOP IT!

apcaccess status

if this shows

STATUS  : COMMLOST

do the following further checks - it could be that UPS is not recognised in USB due to power issue.

lsusb

will list the connected UBS devices. On some umbrel installations, UPS is not recognised on the USB bus and if that happens you would not see that in the output of this command.

umbrel@umbrel:~ $ lsusb
Bus 002 Device 002: ID 2109:0715 VIA Labs, Inc. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
umbrel@umbrel:~ $ 

If this happens on your node, there is an issue and you must check /var/log/syslog

tail -f /var/log/syslog

if you see lots of USB related error messages written of the following description

Jul 26 14:30:55 umbrel kernel: [ 6004.122153] usb 1-1: new high-speed USB device number 122 using xhci_hcd
Jul 26 14:30:55 umbrel kernel: [ 6004.122286] xhci_hcd 0000:01:00.0: Setup ERROR: setup address command for slot 1.
Jul 26 14:30:55 umbrel kernel: [ 6004.330262] xhci_hcd 0000:01:00.0: Setup ERROR: setup address command for slot 1.
Jul 26 14:30:55 umbrel kernel: [ 6004.542121] usb 1-1: device not accepting address 122, error -22
Jul 26 14:30:55 umbrel kernel: [ 6004.670139] usb 1-1: new high-speed USB device number 123 using xhci_hcd

you should stop the apcupsd since your device is not recognising the UPS and filling up the syslog with error messages. If you keep it running UPSD which cannot connect to the UBS device, the syslog will be bloated with these error messages. you can press ctrl-c to stop the output from tail -f

sudo /etc/init.d/apcupsd stop

and

sudo nano /etc/default/apcupsd

In /etc/default/apcupsd change ‘ISCONFIGURED=yes’ to ‘ISCONFIGURED=no’

The implications are that your UPS will protect only for short power outages but would not safely shutdown. We are still looking for solutions for this issue which could be related to the power supply to SSD on some installations.

IF YOUR UPS WAS RECOGNISED and you did not see any issues in syslog as above you are good and proceed below.


Proceed Further

Check UPS status:

apcaccess status

output example:

$ apcaccess status
APC      : 001,035,0900
DATE     : 2021-06-14 02:13:51 +0000
HOSTNAME : umbrelmavic
VERSION  : 3.14.14 (31 May 2016) debian
UPSNAME  : myups
CABLE    : USB Cable
DRIVER   : USB UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2021-06-13 01:38:35 +0000
MODEL    : Back-UPS ES 350
STATUS   : ONLINE
LINEV    : 120.0 Volts
LOADPCT  : 0.0 Percent
BCHARGE  : 100.0 Percent
TIMELEFT : 36.4 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
SENSE    : High
LOTRANS  : 88.0 Volts
HITRANS  : 139.0 Volts
ALARMDEL : 30 Seconds
BATTV    : 13.7 Volts
LASTXFER : Unacceptable line voltage changes
NUMXFERS : 1
XONBATT  : 2021-06-13 01:50:34 +0000
TONBATT  : 0 Seconds
CUMONBATT: 251 Seconds
XOFFBATT : 2021-06-13 01:54:45 +0000
STATFLAG : 0x05000008
SERIALNO : XXXXXXXXXXXX
BATTDATE : 2007-06-08
NOMINV   : 120 Volts
NOMBATTV : 12.0 Volts
FIRMWARE : 823.B1.D USB FW:B1
END APC  : 2021-06-14 02:13:55 +0000

Once the output looks correct, specifically the STATUS shows as ONLINE, you can test the setup by disconnecting the UPS from the main power, watch the message prompts on the terminal and and let the battery drain until the point that a showdown will be initiated, this will confirm that your setup is correct.