Need some advice. Shutdown servers when environment changes.

I have a little school knowledge of circuits, and some programming knowledge in real time systems, so I am not a complete noob. But this is probably a noob type of question. I have searched google, and not found a straightforward answer, so I am posting here in hopes that I can get some guidance before I fry my first UNO....

I wish to sense the environment in the server room, temperature and 110 A/C power, then shutdown servers (via USB comm) if the temp gets too hot or the power fails. The temperature I got, thanks to a great example sketch and affordable parts.

My simple solution for the power question is:

Can I just purchase/scavange a 5 VDC wall wart, and plug it into an unprotected (no UPS) outlet, and wire directly to the arduino digital pins? When the power fails, the wall wart will drop the pin from +5 to 0, and I can take action as I choose. My question is should I use a current limiting resistor in the circuit? Perhaps a 4.7K ohm? Should I use an optoisolator even if my voltage is only 5VDC?

As an alternative, I thought I could just connect an external 9VDC wall wart to the arduino. Is there a register I could test in the arduino that would tell me if I am running on USB or external power? Does plugging in an external adapter to the arduino physically disconnect the USB power? I see that the arduino power conector has 3 connections, does it disconnect USB power when you use the external connector? Ideally, I would like the arduino to switch power sorce to USB when the external power fails.

Finally, if there is no register, and the USB power is not physically disconnected, I am thinking of using a voltage divider to drop the 9VDC to 4.5 VDC and sense on an analog pin. Would this work?

Thanks for your help. I hope this is not too noob or covered elsewhere.

Finally, if there is no register, and the USB power is not physically disconnected, I am thinking of using a voltage divider to drop the 9VDC to 4.5 VDC and sense on an analog pin. Would this work?

If have seen such solution been mentioned ealier on the forum so I guess yes.

However if the wall wart stops (no 110Volt) what keeps the server running? Do you have an UPS? These often have a serial out line that can be connected to the server.

I can get really into providing long explanations, which too often go unread, so I try to keep it short and simple, leaving out info that is not really necessary.

1) Can you provide a keyword I might search on to find this similar solution? I have tried, and I am not finding it short of reading every post in the forum.

2) Yes there is a UPS, it does not sense temperature, and it is currently hooked up to the PBX, so that is not an option.

Thanks for your quick feedback. Can you help?

You have most of the short answers...

See the thread below on push button Power... Same question really.

You are re-designing the control circuitry for a UPS. Why not use a UPS?

OK there are UPSes and there are other ones...

Some of them have intelligent interfaces that can signal multiple units, dial phone numbers and so on.

Even the USB ones can be tapped for the control signal -- many of them use a RS232 to USB cable -- most APC models for example.

I thought I made an intelligent suggestion. Maybe not. :(

As usual - no model numbers no equipment types so it is guessing in the dark.

BTW -- if the phone line is internal -- voltage might disappear. If it is external -- the telco "floats the line". So no -- the voltage does not drop out in that case.

Even so this is a really simple project for an Analog input on arduino -- with a rechargeable battery backup.

So yes it can be done.

Yes you can. You can run the arduino from usb power on a server that’s on the UPS and connect an opto-isolated wall-wart on a non UPS outlet to an arduino pin to read it. You’ll presumably need a program running on the server to read serial data from the arduino telling it to send instructions to other servers (or itself) to initiate shutdown. You can put most of the smarts in the server program and provide graceful degredation - shutting down less critical systems first to see if you can keep the temp within limits while maintaining some functionality in the server farm.

Should you do it? Probably not. You will not be Mr. Popular the first time a bug in your code in either place decides to shut down systems unnecessarily. Depending on where you work, you might well be Mr. “Looking for new employment”. Testing it will be a bit of a challenge too if your datacenter is 24x7.

Thank you all for your helpful replies. I will be happy to be more detailed, now that I have the answers (I know, I got it backwards, but I have found that providing too much detail up front, people tend not to read...

I have a server room on-site with a dozen servers. Mostly Linux, but some Windows too. I can write some scripting to query the arduino on a per minute basis, and get temperature and power status. The UPS will hold for about 20 minutes, so I know not to shutdown until the power has been out for about 10 minutes (hmm gotta think about 10 consecutive 9 minute outages too, I guess). It is a small closet that is cooled by a standalone AC unit, hooked to another UPS (not my doing). This UPS is a smart UPS, and the PBX guy stole the signal port for use with his PBX. I could steal it back, but it will become a back and forth deal, so I will just let him have it. He won't touch the arduino, because he won't know what it is...

My plan is to plug the arduino into a Linux USB port and let my script do the decision making. When I decide a shutdown is needed, I will send a command via ssh to the linux boxes, and a net shutdown command to the windows machines. Of course, I will get an email and an SMS message long before any shutdown occurs. I am not far away, so when I am ready, I can visit and bring everybody back up.

I will post the schematic, sketch and scripts when I get it working, so that others can share.

Thanks again for the advice. I will order some optoisolators just for the heck of it.