Article sections

    1. Introduction

    This document provides a step-by-step guide to setting up and configuring an APC SRV3KUXI-IN UPS on a Raspberry Pi using apcupsd for power management and monitoring.

    2. Hardware Requirements

    • APC SRV3KUXI-IN UPS
    • Raspberry Pi 3B+ or newer
    • USB-to-Serial Cable (Exar XR21V1410 USB-UART IC)
    • APC Smart-UPS Serial Cable (APC 940-0024C / 940-0095B / 940-1524D recommended)

    3. Checking USB Detection

    Before installing apcupsd, verify that the Raspberry Pi detects the UPS connection:

    lsusb

    Expected output should contain:

    Bus 001 Device 004: ID 04e2:1410 Exar Corp. XR21V1410 USB-UART IC

    Check available serial ports:

    ls /dev/ttyUSB*

    Expected output:

    /dev/ttyUSB0

    4. Installing and Configuring apcupsd

    4.1 Install apcupsd

    sudo apt update
    sudo apt install apcupsd -y

    4.2 Configure apcupsd.conf

    Edit the configuration file:

    sudo nano /etc/apcupsd/apcupsd.conf

    Modify these lines:

    UPSCABLE smart
    UPSTYPE apcsmart
    DEVICE /dev/ttyUSB0

    Save and exit (CTRL + X, then Y, then Enter).

    4.3 Restart apcupsd

    sudo systemctl restart apcupsd

    5. Setting the Correct Baud Rate

    If communication is lost, set the baud rate manually:

    sudo stty -F /dev/ttyUSB0 2400 cs8 -cstopb -parenb

    Verify:

    stty -F /dev/ttyUSB0

    Expected output:

    speed 2400 baud; line = 0;

    6. Making Baud Rate Persistent

    Edit /etc/rc.local to apply settings at boot:

    sudo nano /etc/rc.local

    Add the following line before exit 0:

    stty -F /dev/ttyUSB0 2400 cs8 -cstopb -parenb

    Save and exit, then make it executable:

    sudo chmod +x /etc/rc.local

    Create the systemd service:

    sudo nano /etc/systemd/system/rc-local.service

    Add:

    [Unit]
    Description=/etc/rc.local Compatibility
    ConditionPathExists=/etc/rc.local
    After=network.target
    
    [Service]
    Type=forking
    ExecStart=/etc/rc.local start
    TimeoutSec=0
    RemainAfterExit=yes
    GuessMainPID=no
    
    [Install]
    WantedBy=multi-user.target

    Enable and start the service:

    sudo systemctl enable rc-local
    sudo systemctl start rc-local

    7. Checking UPS Status

    To verify UPS communication:

    apcaccess status

    Expected output:

    STATUS   : ONLINE
    LINEV    : 235.8 Volts
    OUTPUTV  : 229.8 Volts
    BCHARGE  : 100.0 Percent
    TIMELEFT : 999.0 Minutes

    8. Additional Commands for Troubleshooting

    • View UPS logs:sudo cat /var/log/apcupsd.events
    • Test UPS communication:sudo apctest
    • Monitor real-time UPS status:watch -n 1 apcaccess status

    9. Conclusion

    You have successfully set up your APC SRV3KUXI-IN UPS on Raspberry Pi using apcupsd. The UPS is now capable of monitoring power status, battery health, and auto-shutdown when necessary. If any issues arise, refer to the logs and test commands for troubleshooting.


    in PowerRaspberry-PiZabbix