Tips & Tricks Blog
Notes, ideas and general comments on anything related to high-tech.

November 28, 2020

Converting Old UPS to Power Control Box

Filed under: Uncategorized

This simple contraption was quickly put together a few years ago to allow remote power control over WiFi or USB dongle. It can be set up to work as a WiFi access point serving its own SSID or as a client connecting to an existent WiFi network. In order to control the power one has to connect over ssh. When connected a simple menu is presented for configuring the device or powering the outlets on or off.
Entering “s” (undocumented) while in the top level menu drops you into the shell.
Note: initially I had USB dongle connected permanently, but it was causing the board to drop into the bootloader prompt on boot when powered up without a PC connected.

The hardware:

It was made with old CyberPower 425VA plus Olinuxino A13 WiFi with relays module.
The power is fed to Olinuxino directly from the battery feeds. The battery is stored outside and connected to the red and blue terminals.
The outlets were rewired to be powered through the Olinuxino controlled relays.

The software:

Start with the pre-built image from here:
https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/A13/A13-build/A13_olinuxino_Debian_kernel_3.4.90%2B_image_description.txt

The image file name is:
A13_debian_34_90_WIFI_RALINK_GCC_GPIO_X_I2C_100KHz_UVC_TS_FTDI_3G_video_accell_release_10.img
It’s big (almost 4GB), so torrenting it is the best option.

I’ll keep a copy on google drive till need to free up space:
https://drive.google.com/file/d/1DzbFk9hplX51KZCa82LuA3gB7mFvIfCW

The more detailed image flashing instructions are here:
https://www.olimex.com/wiki/Prebuilt_SD_card_images_running_debian

Install hostapd and dnsmasq:
https://www.olimex.com/forum/index.php?topic=1635.0

Pull (using GIT) or download and extract files from the repo (URL below) into “/ups” folder on the board:
https://github.com/dob71/olinuxino-powerctl

Set up the init script:
ln -s /ups/init.d/powerctl /etc/init.d/powerctl
/usr/sbin/update-rc.d powerctl defaults

Add user “admin” and set /usb/control as its shell in /etc/passwd.

Edit /etc/inittab to respawn getty with admin login instead of root on ttyS0
T0:2345:respawn:/sbin/getty -L -a admin ttyS0 115200 linux

Example session (the control board is in client mode connected to home WiFi):

$ ssh admin@192.168.1.152
Warning: Permanently added '192.168.1.152' (ECDSA) to the list of known hosts.
admin@192.168.1.152's password:
Linux a13-OLinuXino 3.4.90+ #1 PREEMPT Thu Jun 19 09:51:45 EEST 2014 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Nov 28 02:30:35 2020 from some.host.okob.net
Please press a key:
'w' - control WiFi, 'p' - control power, 'r'- admin password.
The system is in STA mode
Wireless device state:
wlan12    Link encap:Ethernet  HWaddr 48:02:2a:ea:11:1f
          inet addr:192.168.1.152  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:854 errors:0 dropped:4329 overruns:0 frame:0
          TX packets:251 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:173505 (169.4 KiB)  TX bytes:39336 (38.4 KiB)
'c' - client mode, 'a' - AP mode, 'e' - exit:
'w' - control WiFi, 'p' - control power, 'r'- admin password.
Current power state:
R1(surge outlet 1) : on
R2(surge outlet 2) : on
R3(surge outlet 3) : on
R4(battery outlets): on
1-4 toggle the state, 'u' - all on, 'd' - all off, 'e' - exit:
Current power state:
R1(surge outlet 1) : off
R2(surge outlet 2) : off
R3(surge outlet 3) : off
R4(battery outlets): off
1-4 toggle the state, 'u' - all on, 'd' - all off, 'e' - exit:
Current power state:
R1(surge outlet 1) : on
R2(surge outlet 2) : on
R3(surge outlet 3) : on
R4(battery outlets): on
1-4 toggle the state, 'u' - all on, 'd' - all off, 'e' - exit:
Current power state:
R1(surge outlet 1) : off
R2(surge outlet 2) : off
R3(surge outlet 3) : off
R4(battery outlets): off
1-4 toggle the state, 'u' - all on, 'd' - all off, 'e' - exit:
Current power state:
R1(surge outlet 1) : on
R2(surge outlet 2) : off
R3(surge outlet 3) : off
R4(battery outlets): off
1-4 toggle the state, 'u' - all on, 'd' - all off, 'e' - exit:
Current power state:
R1(surge outlet 1) : on
R2(surge outlet 2) : on
R3(surge outlet 3) : off
R4(battery outlets): off
1-4 toggle the state, 'u' - all on, 'd' - all off, 'e' - exit:
Current power state:
R1(surge outlet 1) : on
R2(surge outlet 2) : on
R3(surge outlet 3) : on
R4(battery outlets): off
1-4 toggle the state, 'u' - all on, 'd' - all off, 'e' - exit:
Current power state:
R1(surge outlet 1) : on
R2(surge outlet 2) : on
R3(surge outlet 3) : on
R4(battery outlets): on
1-4 toggle the state, 'u' - all on, 'd' - all off, 'e' - exit:
'w' - control WiFi, 'p' - control power, 'r'- admin password.
Connection to 192.168.1.152 closed.


Home

OkOb.net Tips & Tricks Blog
Powered by WordPress