On 2011-10-17 17.34, mailing list wrote:
> I have a machine running OBSD 4.4 which as an APC Back-UPS ES 550.
> Anyway to have OpenBSD detect when power is coming from Battery?
> (Plan on sending the system sending me an sms if so)

Apart from the suggestions elsewhere in the thread, in the good old days
I used to detect power outages by simply using a 12V power adapter and
soldering together a special cable connecting the +12V to the DCD pin of
an RS 232 serial connector.

Then I plug the adapter into a wall socket and connect the cable to a
serial port on the computer, then simply open() the serial device and
issue a blocking read().

If/when the read() later on returns EOF, I know that the carrier has
been dropped, thus I have no power from the wall. (And since the program
is obviously still running, what power I have must come from the UPS.)

Then give it a grace period of a few minutes (as long as you dare with
whatever UPS and load combination you have), then check again. If DCD
is still out, shut down the machine in a controlled fashion. Otherwise
lather, rinse, repeat.

Can't be any simpler, really. :-)


Best regards,
/Benny

> I found the following: http://www.apcupsd.com/
> My understanding is you need a usb connection to the ups. (one I have has no
> USB)
> 
> Anyone know of a package using detection over voltage changes (or
> something)?
> 
> Thanks

Reply via email to