Introduction: Monitor an Older UPS Status With a Raspberry Pi
Here is a small mod I made for an OPTI-UPS VS575C.
The ups has a serial port and works well with Windows, along with a serial to USB adapter and the Opti-UPS ‘Sentry’ software, the UPS can tell Windows when it has switched to battery mode on an AC power failure. This allows Windows to shut down properly if needed.
The Sentry software is not available for Linux and the serial data is non-standard and not easy to decipher. It’s not even supported by NUT (http://www.networkupstools.org)
So I decided to use the front LED’s on the device to ascertain the current state of the UPS, the green LED means the UPS is on AC mode, orange means battery mode.
I took the UPS apart and soldered two wires to the battery mode LED, fed these outside of the UPS and hooked them up to a Raspberry Pi’s GPIO port and ground.
Now when the AC power fails, the UPS sends 1.8v to the front LED and the Raspberry Pi reads a logic 1 on it’s GPIO pin (pin 5 set as an input).
This means I can monitor that pin with a BASH script, and have the script shutdown my NAS, and other networked devices all being powered by the UPS - over SSH.
The example script I've made checks the GPIO pin every few seconds, and if it reads a "1" then the AC power is down, It then sends me a push notification to my iPhone using Prowl/Growl. If the AC power remains off for longer than 30 seconds the script issues a shutdown command to my NAS drive. The GPIO pin is then monitored again, until the power is restored, then it sends a WakeOnLan packet to the NAS to power it up again.
You'll need to enable passwordless ssh logins to your own devices if you use this same method.