Project title: Power failure sensor for the genpowerd UPS daemon
By: Michael Balcos (December 2005)
url: http://slugphils.homelinux.org/ups.txt
Released in the GNU Free Documentation License

Introduction of the project
---------------------------
I used to utilize contact closure UPSes. However, smart UPSes are becoming
more popular these days. When I recently bought a new UPS, it was a smart UPS
with a protocol I couldn't figure out. So what I did is rather make a "power
failure sensor" that could work with genpowerd in recent releases of
Slackware Linux. I have successfully used this project with Slackware 9. The
steps should be fairly the same for more recent Slackware releases.

What this project does is tell a Slackware Linux box if a power failure has
occured. If so, a shutdown scheduled for 1 minute is initiated. If power is
restored within 1 minute, the shutdown is cancelled. If not, the shutdown
commences.

Hardware components
-------------------
12V DC adapter
DC crown for the DC plug of the DC adapter (optional; you may rather connect
     the adapter directly)
Relay with 12V DC coil; contacts may carry a current as low as 1 ampere; I
     used a SPDT relay for this project
10 Kilo-Ohm resistor (1/2 watt)
A board to interconnect the parts
A female DB9 connector
Ribbon cable (used to connect the DB9 connector to the hardware component
     of this project)
Solid wire for connecting components (if you will not make a PCB)
Stranded wire for connecting the coil to the DC crown (only necessary if you
     wish to use a DC crown)
Casing for the finished hardware

Software requirements
---------------------
Slackware 9 (or later versions) installed with genpowerd is required. (Other
distributions can use this solution as well as long as you get genpowerd
installed properly and make the necessary adjustments in this documentation.
Other power daemons can also be used should they support contact closure
UPSes, but how to do that is beyond the scope of this documentation.)


The hardware
------------
Connect the hardware components as follow:

Relay>   Normally o   Coil o---- 12V DC (+ or -)
Relay>   Closed  
Relay>              Contact o---- GND (Serial port)(pin 5 if DB9)
Relay>
Relay>   Normally o   Coil o---- 12V DC (- or +)
         Open     |
                  |
                  +------------------------o DCD (Serial port)(pin 1 if DB9)
                        |
                      +---+
                      |   | Resistor
                      |   | 10 Kilo-Ohm
                      |   | 1/2 Watt
                      +---+
                        |
                        +------------------o DSR (Serial port)(pin 6 if DB9)
                        |
                        +------------------o DTR (Serial port)(pin 4 if DB9)

* Relay is at bottom view. "Normally closed" contact is not used.

After completing the interconnections, give your hardware project a casing.

The software
------------
Open /etc/inittab with your favorite editor and look for the following line:

pf::powerfail:/sbin/genpowerfail start

Change it to:

pf::powerfail:/sbin/shutdown -h +1

Look also for the following line:

pg::powerokwait:/sbin/genpowerfail stop

Change it to:

pg::powerokwait:/sbin/shutdown -c

Finally, open /etc/rc.d/rc.local with your favorite text editor and
append:

/sbin/genpowerd /dev/ttyS0 powerd

* change /dev/ttyS0 to the serial port used for the project if necessary

Reboot the machine for testing. You may get a "shutdown pid not found"
message after completing the reboot. It is safe to ignore it. genpowerd makes
the system "cancel" a shutdown at startup, but since there is no shutdown
process, it will give the mentioned message.


Yahoo! Photos
Got holiday prints? See all the ways to get quality prints in your hands ASAP.
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
[email protected] (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph

Reply via email to