RPi Control Your Server PSU Over The Internet

remote-server-psu-control-via-RPi

Here’s an interesting use of a Raspberry Pi to control the PSU on a server. [Martin Peres] is going to be away for a few months and still wants access to his PC. This isn’t really all that tough… it’s what SSH is made for. But he also wants lower-level access to the hardware. Specifically he needs to control and get feedback on what the PSU is doing, and even wanted to have access to the serial console without having to go through the computer’s NIC.

The image above shows one part of his solution. This is a custom Ethernet port that connects to his Rasberry Pi header breakout board. Inside the computer the jack is wired to the motherboard power LED to give feedback about the current state of the power supply. It also patches into the green wire on the PSU, which lets him turn on the power by pulling it to ground. After working out the cable routing he developed a web interface that makes it easy to interact with the setup.

As with other hacks along these lines letting an embedded computer run 24/7 is a lot less wasteful than leaving a PC on. That’s a concept we can really get behind.

49 thoughts on “RPi Control Your Server PSU Over The Internet

  1. I like it, a poor man’s BMC. I’m sure the whole setup costs less than the option to add one to a commercial server.

    Next step would be to piggyback on the SMBUS to read the motherboard sensors.

    1. Well the RPI is $50, I imagine you could make a wake over lan solution for cheaper, I’m not sure but I bet some routers support that, or maybe a basic netbook would work too.

          1. I think it can, UPS systems can issue a shutdown command to computers on a network, I’m not sure if it is something software based or not though,

    2. +1 on the BMC.
      HP 54L BMC = 60 GBP
      RPi = 30 GBP
      BMC will do VNC all the way from BIOS to OS, temp, voltage and fan RPM monitoring, SNMP, remote CD emulation, remote serial and other things I’ve forgotten.

      This is a nice hack – but at the end of the day you get a hell of a lot more with a BMC. Of course your server has to support it. IPMI / vPRO+AMT FTW.

      1. You could do full blown BNC with rpi. You would need
        $5 USB Video grabber
        $14 vga to video Converter
        some code to emulate ps2 keyboard/mouse with rpi GPIOs or additional ATTINY.

        Yes, it wont be perfect, but it will work and still be cheaper than HP thingie :)

        1. I’ve never seen a USB video grabber for less than twice that. Similar for the VGA / video converter, only seen those for MUCH more! Where are you getting your prices?

          I suppose one might FPGA something up to use HDMI, over in projects-that-never-happened land.

          But wouldn’t it be easier to just install software to do the screencapping? For the boot sequence, I think quite a few servers can divert the BIOS screens to a serial port.

      2. I’ve done firmware development for servers for a little while. I too have learned how useful a BMC can be and would love to duplicate some of the functionality as some sort of inexpensive add in for commodity hardware.
        Video redirection is one of the few things this needs to be a real powerful tool.

        It might be beyond hacker level, but being able to connect a raspi to the system’s PCIe interface and have it present an option ROM to the system (or two in order to cover legacy 16 and UEFI systems), there is a lot more things that would be possible :)

        1. Google has been kind enough to write an option ROM (sgabios) that allows a serial port to display the text portion of the video interface and emulate a keyboard. For textmode only servers this is great, as you can get BIOS-to-prompt control of a system.

          If you’re lucky enough to have a board supported by Coreboot, this is easy, but if you don’t you might be able to abuse an old PCI NIC’s option ROM socket.

          1. Check your BIOS for ‘legacy serial redirection’, it may already have this feature. For something like Linux and some MS server OSes, they can do a seamless handoff of this serial port so you keep a text console seamlessly from preboot through bootloader through to the OS.
            We might get to see new systems start to make use of networking in the not to distant future to provide a preboot console interface without the need for add in hardware.

          2. @matt:
            sgabios uses int 10h like some of the commercial BIOS legacy redirection, so it gets shut down once the IDT gets rewritten by the kernel. Anyway I thought it might be a good option stuffed into an option ROM somehow for BIOSes that don’t have it. Since OP didn’t have the option for a BMC like most servers do, I’d be surprised if he had the option for serial redirection in BIOS. It’s been a while since I’ve had my hand in BIOS, but I think AMI makes you pay extra for all but a very basic legacy redirection module in Aptio, and consumer board OEMs don’t like paying for anything but the bare minimum…

            This is why I really like u-boot’s netconsole.

  2. Sure, ssh in is great. I had a BFG graphics card act burn up whilst I was away for 2weeks in China. No more ssh. Nothing a remote power switch could contol either. Of course, this could be any part in a chain of low cost vendors in a PC that could send the machine south. HDs, cards etc.

  3. an easier and more extendible option is to set your bios to start the server after power failure. Then it is a matter of relay switching (multiple projects for home automation/remote light switching available). multiple relays give control over multiple pc’s without soldering when replaced.

    That said, it is a cool and integrated solution.

      1. I think that was Bitflusher’s idea. Have some relays, controlled by a networked-up microcontroller, in the mains power lines to each server. So a simple login and command to your MCU can cut the power. Then power back on, and the PC sorts itself out, as per the BIOS settings he mentions. Bit ugly. but practical.

        A refinement would be to tie in with the power button on the front of the PC. Use a relay, or just a transistor, to simulate pressing the power button, from the MCU I mention. Then if it doesn’t seem to have worked, cut the power for real. Or cut the power anyway after a minute or so to shut down.

        1. That’s basically what I did. I wanted to use an external relay for cutting the PSU’s power supply, but relays require some power to operate and I was afraid the power supply for my RPi wouldn’t be sufficient (USB cable connected to a USB switch).

          Seriously though, what you propose is very close to what I provide. Except that I decided to go for the RPi instead of a networked-up µc. But if you know about an of-the-shelf µc with ethernet capabilities cheaper than the RPi, I’m interested!

          The RPi’s benefit too is that is runs Linux and I was able to set up a real nice web service (written in C++/Wt) with updates handled in a push-fashion. So, the logs and the state of the LED are updated in real time!

  4. Yes you could do the same thing with a Pogo plug, Arduino, or hacked router. Still a neat hack with a Pi because it is not expensive and frankly you could add other functions to it.

  5. Something like the small expandable up to 8 port – mains relay gadget I built a few years ago with addressable outputs controlled over serial / USB serial. (PIC 16F628 / FT232 / Crydom SSRs)
    One configuration option is to have the serial/USB port monitor for a heartbeat from a host – and if it times-out – then output 0 turns off for 10 secs, and powers on again (if it was on previously – with appropriate beeps and warnings!)

  6. Hey, thanks for featuring my project on Hackaday.

    For people suggesting me to use WoL or any other software-based solution, there is one thing you must know about this computer. This computer is used for the sole purpose of reverse engineering nvidia cards. I work on power management and fiddle with the clocks. Often, when I crash a card, everything just freezes (BIOS included) and the only option that’s left for me is to unplug the power plug.

    This isn’t a big deal usually, but now that I am away of the computer, I needed to be able to cut the power remotely –> that’s the hack :)

    For the full story, check out my website: http://mupuf.org/blog/2013/05/11/wtrpm-a-web-based-wt-suite-to-power-up-slash-down-your-computers/

      1. Yeah, I considered it (it is explained in the full article) and I actually used that on the other computer (cathaou) because I didn’t have time to build the circuit for it. The problem is that I haven’t tested how reliable it is and when I’m reverse engineering, I don’t want to wait 30 seconds before the computer reboots (yes, I crash the computer THAT often). Oh, and using a software solution doesn’t tell you when you computer is booting or why it doesn’t boot. The LED indicator + the serial console help for that.

  7. Hey, thanks for featuring my project on Hackaday.

    For people suggesting me to use WoL or any other software-based solution, there is one thing you must know about this computer. This computer is used for the sole purpose of reverse engineering nvidia cards. I work on power management and fiddle with the clocks. Often, when I crash a card, everything just freezes (BIOS included) and the only option that’s left for me is to unplug the power plug.

    This isn’t a big deal usually, but now that I am away of the computer, I needed to be able to cut the power remotely –> that’s the hack :)

    For the full story, check out my website: http://mupuf.org/blog/2013/05/11/wtrpm-a-web-based-wt-suite-to-power-up-slash-down-your-computers/

    1. Why did you not also use the hardware reset? Seems easier than the power and should work as well most of the time. That way you could save the big power down for really major events.

    1. Well done! This is indeed what I should have done.

      The main reason I went for the RPi was that I didn’t have much time available to work on the hw-side of things (I can only work on that at my hackerspace, one night every week). But since I got a RPi, I also use it to get a serial console on this server along with some other small services.

      Anyway, you did a very good job with your project!

  8. WOL is great and everything but it only works if the computer is in a state that will allow being woken up. Sometimes, it is useful to reboot a machine, and this does that job very well. I have wanted a remote management solution for a desktop PC that I use as a server for a long time and this does the trick. Of course it would be nice to remotely view the video output too, and allow remote keyboard/mouse so that BIOS changes can be made, but that is less necessary (My requirement does not justify server class hardware).

    1. Yes it would. But why trust the BIOS, if you design the suite to be able to control this relay, you can control the PSU and the power button just as easily.

      The problem with having a relay is that I have very limited power available (the RPi is driven by USB) and I was afraid it would drain too much current. In the end, driving the PSU was easier and safer (not dealing with 230V).

  9. One little SNAFU in waiting is having an RJ45 port right near where the real Ethernet port should be. At least, it’d be good to know that neither end would fail too disastrously if you plugged a real network cable in. That’s the reason computers used to have so many different shaped and sized sockets! You might want to think about using some otherwise-unused type of socket, maybe a D-type or DIN or whatever else. It doesn’t matter what I suppose, since it’s all slow signals and low DC voltages.

  10. I’ve had remote management servers (the tiny chip providing the BMC, iKVM, etc) crash. That’s quite an annoyance because they are separate from the front chassis power-button, and requires literally yanking the plug to fix. This (with external relays) would reboot them.

  11. I did something similar but more limited in scope. Had a remote machine that I would connect to over dail-up only (no internet service where it was). Basically, I put together a separate DC power source, a 4017 decade counter, a 555 timer, and a relay hooked up to the reset switch on the remote machine and to the phone line looking for a ring signal. Remote machine was supposed to answer on the 6th ring. The counter counted each ring, and if the remote PC didn’t answer by the 8th ring (i.e., machine was locked up or unresponsive), it would close the reset switch for about 4 seconds and reboot the remote PC. I just had to wait a couple minutes and dial in again.

Leave a Reply to JoeCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.