My Eaton 5P UPS has dual connectivity: USB and serial. As most OpenWrt capable SOHO routers has USB port rather than serial, it is simple to connect the UPS to the router by USB.

My experience is that if the Eaton 5P UPS switches to battery and back to mains relatively often, USB connection may be broken. Serial connection seems to be more reliable.

Hardware setup

You will need:

  1. NUT compatible UPS with serial port interface.
  2. Good quality USB-serial adapter/cable (FTDI or CP210X chipset are recommended).
  3. OpenWrt router with USB port.
  4. Cables for wiring.

My setup: Eaton 5P UPS, FTDI based USB-serial adapter and an old Asus WL-500G Premium V2 router. Basically you can use your USB capable OpenWrt router and USB-serial adapter.

|......................... My setup ........................|
|                                                           |
| OpenWrt <---- USB ----> USB-serial <---- serial ----> UPS |
| router                   adapter                          |

|...................... USB only setup .....................|
|                                                           |
| OpenWrt <------------------ USB --------------------> UPS |
| router                     cable                          |

IMPORTANT! Do not use serial and USB ports of the Eaton 5P UPS in the same time.

Software setup

NUT offer usbhid-ups driver for USB connection and mge-shut driver for serial connection.

By default packaged version of NUT in OpenWrt 18.06 does not include serial support, and it must be recompiled. After that, the NUT packages can be uploaded to the OpenWrt router and installed manually.

Download the source tree. Choose the branch according your OpenWrt/Lede version.

git clone -b openwrt-18.06
cd openwrt

Download and prepare feeds.

scripts/feeds update -a
scripts/feeds install -a

Find LEDE_BOARD and LEDE_ARCH variables in /etc/os-release. These are your OpenWrt target and subtarget.

LEDE_BOARD="brcm47xx/legacy" # Example board.
LEDE_ARCH="mipsel_mips32"    # Example arch.

Launch OpenWrt Configurator.

make menuconfig

Select the appropriate settings in the OpenWrt Configurator. Choose your target, subtarget and target profile according to your router.

Target System -> Broadcom BCM47xx/53xx (MIPS) # Choose your target.
Subtarget -> Legacy (BMIPS3300)               # Choose your subtarget.
Target Profile -> Asus WL-500gP v2            # Choose your target profile.
[*] Advanced configuration options (for developers)
[*] Build the OpenWrt SDK
Kernel modules --->
 USB Support --->
  <M> kmod-usb-serial
Libraries --->
 <M> libusb-1.0
 <M> libusb-compat
Network --->
 <M> nut --->
  [*]   Build with support for USB drivers
  [*]   Build with support for serial drivers
  <M> nut-driver-mge-shut
  <M> nut-driver-usbhid-ups
  <M> nut-server
  <M> nut-upsc
  <M> nut-upscmd
  <M> nut-upslog
  <M> nut-upsrw
  <M> nut-upssched
Note that target, subtarget and target profile are just examples.

Compile the base system. This takes long time.


Compile NUT packages.

make package/nut/download V=99
make package/nut/prepare V=99
make package/nut/compile V=99
make package/index

Packages are built in the bin/packages/<ARCH>/packages/ directory.

Copy packages to your router via scp.

Install kernel modules for the USB-serial adapter. FTDI, CP210X, PL2303 are common USB-serial adapter chips.

opkg install kmod-usb-serial-<ftdi|pl2303|cp210x>.

Install NUT components.

opkg install nut_2.7.4-7_mipsel_mips32.ipk
opkg install nut-common_2.7.4-7_mipsel_mips32.ipk
opkg install nut-driver-mge-shut_2.7.4-7_mipsel_mips32.ipk
opkg install nut-driver-usbhid-ups_2.7.4-7_mipsel_mips32.ipk
opkg install nut-server_2.7.4-7_mipsel_mips32.ipk
opkg install nut-upsc_2.7.4-7_mipsel_mips32.ipk
opkg install nut-upscmd_2.7.4-7_mipsel_mips32.ipk
opkg install nut-upslog_2.7.4-7_mipsel_mips32.ipk
opkg install nut-upsmon_2.7.4-7_mipsel_mips32.ipk

Now, NUT can be configured to use serial port using /dev/ttyUSBX device.