Hacker News new | past | comments | ask | show | jobs | submit login
DIY out-of-band management: remote power button (stapelberg.ch)
165 points by secure on Oct 9, 2022 | hide | past | favorite | 60 comments



At my workplace we had a farm of laptop machines and we weren't allowed to disassemble them to pull any power wires out. What we ended up using was a remotely controlled motor with a small plastic "finger" attached that would press on the power button for n seconds, depress, wait few seconds, then press it for n seconds again to do remote hard reboots.


Had a secure server room with a maglock with very few cardholders and forgot our cards a few times. We wired-up a CD-ROM drive to a server positioned so that it pressed the door unlock button on the wall when it was ejected, so someone could ssh in to the server and "eject /dev/sr0" to get in.



You're kidding me.

It's exactly the role of this robot in Wall-E: https://old.reddit.com/r/MovieDetails/comments/h7r2f2/when_w...



$30 each?!


Found a similar rig set up years ago. The old Tektronix TDS scopes used to lock up in a go/no go test rig and stop responding to GPIB commands. Someone unknown got fed up of it so they wired a relay in a box up as an inline switch for the scope power and drove it from a spare port in a GPIB switch box that the test script talked to. This turned the scope on and off again before each test cycle so it was less likely to crash. This saved hours and hours of failed test runs.


That is awesome and I'm glad somebody did it. But was there some reason not to just pull the laptop batteries and use normal remote-controllable outlets?


> was there some reason not to just pull the laptop batteries and use normal remote-controllable outlets?

What happens when someone accidentally does a clean shutdown from within the OS?

Switchable PDUs have the same issue. You need something like Wake-on-LAN in addition to the switchable power to ensure you don't need to do a late night drive into the data center or office.


BIOS> plug-in behavior> turn on.

This is on by default on all server boards and the toggle was on all consumer boards i've tried.


Recent laptops do not work as well, or at all, with batteries not present.


Do you, by any chance, work for Intel in Gdańsk testing iGPUs for Apple laptops? I heard that story.


I know that HN is crazy about their homelab setups, but please consider whether having a rats nest of jumpers and a breadboard in your comms cabinet is reliable, let alone safe... How about a tweak to the BIOS to auto turn on power, then plug it into a Shelly Plug running Tasmota? You get your remote turn-on, you get a tested, reliable, and safe solution, and you get power use monitoring on top of that.

The difference in price is ~ 10 eur where I'm at, and I'm not including the rest of the BOM of OP:

Shelly Plug S: EUR 25

NodeMCU: EUR 12.5 Breadboard: EUR 3


A smart plug would probably work just as well for most cases, but one downside is that you need to ensure your computer is safely powered off before turning off the smart plug.

Conceptually, pressing the power button seems a little cleaner to me, and also works well with suspend-to-ram (what I originally wanted to do), which the smart plug can’t do.

I’m not too concerned with safety — we’re talking about 3.3V (signal) and 5V (power) here.


Some motherboard BIOS has the “Restore on AC Power Loss” config item with options. I think that’s he is referring to. IIRC, each of which do following:

- “Stay Off”: do nothing

- “Power On”: turn on after AC is reconnected

- “Last State”: turn on after AC is reconnected, only if disconnected while running


Many smart plugs have some sort of energy monitor built in. I imagine you could turn off the plug when the power dropped below, eg, 5W.


You shut down your computer the usual way, from the OS, then toggle the plug to restart it. In case the system hangs during shut down, you'd actually want to know that it's hanging, which you can actually see in the power readings of the plug.

> I’m not too concerned with safety

I'm sorry to state that, but that much is evident from the photos in the blog post (assuming you're author here). While the voltages may look safe to you, the whole contraption is safe just until something goes wrong. Examples:

1. You push around a dangling wire and short out a more powerful circuit.

2. Something on your dev board for development purposes releases the grey smoke. 500mA at 5v may seem low to you, but under the right circumstances might cause a fire. I don't see any fuses or other overcurrent protection in your schematic.

3. Your mainboard gives a defect and runs more that the expected voltages/currents to your dev board. God forbid AC from something else faulty in the electric installation (just saying because I've been zapped from touching the outside of a closed case).

4. Power surges, lightning strikes... Static electricity even...


Part of the motivation of "homelab" for many people is to learn in a practical way. If you're new to electronics or ESP32s, the amount you'd learning doing this is worth far more than 10 eur.


Why would jumpers (specifically, DuPont connectors) be unreliable, or even unsafe? They're literally the method used in every single computer PC case in existence and work fine. I've never had one fail.

I agree, breadboard is slightly problematic, but that could be fixed quickly with a soldered perfboard setup or a quick custom PCB and remove the breadboard component.

The voltages we're talking about here is all 5V, and anything it's connected to should be pretty limited in current carrying capability.


Keep in mind a lot of smart plugs have remarkably low amperage limits.


Really? I've never seen one rated less than 15A, which is the same as NEMA 5-15R receptacles here in the US.


Sonoff R2 is rated at 10A. (I think several other models are as well, as a result of using a 10A relay.)


Right you are. I'm surprised such things can be sold.


Great project but a little too much for the ones of us with only software development skills.

I use smart plugs over Wi-Fi to do that. Shelly Plug S have a small physical button, a web app, a HTTP URL to call to switch the plug on or off. They also have a lot of features that I don't need. Among them MQTT and Alexa/Google integrations. A few bash scripts with curl and I can do everything I need. The price is reasonable and they saved me a lot of time.


I use a couple of Ewelink devices (hardware-equivalent Chinese clone of Sonoff S20 from AliExpress), reflashed with open source Tasmota firmware for the same purpose: remotely controlled power socket, with physical button, connected to WiFi, with HTTP web page and REST API for curl etc, firmware has MQTT support too; I have no idea about Alexa/Google integrations (likewise, I'm not interested in this feature), but the price is bargain, $10/each. Sonoff S26 clones are good for this purpose too, but UART port is easier to solder on S20 (larger one). Soldering UART port is necessary for reflashing to Tasmota, because stock firmware is utter crap.


how do you feel about leaving "Chinese clone" devices plugged in 24/7? do the plugs have a ground pin? do they get hot? do they have CE certification? genuinely interested in this setup and don't answer if too prying. thanks


Ground/PE pin is there, in passthrough mode at least (I'm using European/Schuko version). CE certification is obviously missing (in Conformité Européenne sense I mean, China Export is there), but hardware is 1:1 clone of Sonoff, so I don't worry too much about safety. The device looks like a mass produced in a factory, not a homemade solder in a garage. Temperature isn't hot, looks normal to me. ESP8266 chip is the same, the rest (a few Y caps, resistors, LEDs, pushbutton etc) I'm pretty sure is chinese crap anyway, regardless of whether this is Ewelink or genuine Sonoff. Local suppliers here in Ukraine are selling Ewelinks reflashed to Sonoff firmware as genuine Sonoffs anyway, so I see no point in spending more.


thanks very much for all the info


Hardware can be a fun change of pace if you’re willing to try. A lot of stuff is pretty safe as long as you follow basic precautions.

I built my own remote garage door opener with an esp32, relay, and Amazon dash button. Took a bit to get working but super satisfying when you do :)


> Great project but a little too much for the ones of us with only software development skills.

It's a transistor, a resistor, and some wires. The ESP32 boards are trivial to program even without embedded-specific development experience, using just the Arduino IDE and a USB cable.


Agreed. The Shelly looks to be targeted at EU markets. I suppose the more American equivalent would be something like a Meross

Meross Smart Plug Mini https://a.co/d/ey2LJcb


It's 3 components, a bread board and some wire. I would encourage any "software only" people to give it a go :) The software side (MQTT, ESPHome, Docker) of this is far more complex than setting up the hardware.


This. Most mainboards can be configured to boot the moment they receive power, no need for a power button.

It's also worth noting that any internet integration can be disabled on all Shelly devices.


The rationale to justify the wifi link is interesting, and this is a creative solution indeed!

In the past I've used wake-on-lan cards but with the wake signal connected to the reset line instead, so it became reset-on-lan. That's much more useful in my lab, I don't know about yours!

Edit: Writeup: https://www.i3detroit.org/reset-on-lan-an-ethernet-aware-rem...


This is a neat writeup. I think the ESP32, alongside similar microcontrollers that tie communication via complex protocols so close to direct interaction with the physical world for such a small energy cost, are really amazing for teaching, inspiring, and empowering otherwise "non-technical" people. Of course, you do have to be able to program, but I think we're making great strides in making that as easy as possible with things like CircuitPython and EduBlocks.

Also, this kind of shocked me:

> none of my followers had ever seen functioning WOL on any 10 Gbit/s card.

Those cards are way too expensive to be lacking such a useful feature!


It seems likely that most existing deployments of 10Gbps cards are into a machine that has an alternative management card (which has no reason to be 10Gbps-capable).

I don’t need to WoL via my 10Gbps card near as much as I need WoL on the management interface.


That makes sense, I suppose! Maybe if/when 10Gbps becomes more popular with consumers such highly integrated cards will come onto the market.


We’re already starting to see 2.5 Gbps interfaces become more and more popular on mainboards, so I suspect once 10 Gbps interfaces become more common on high-end mainboards, vendors will start caring about WOL with these chips :)


Unfortunately, at the current adoption rate, that will be sometime after 2040.


No electronics skills, flashing of firmware, etc. is needed. Just order a USB relay board and hook NO and COM terminals to the power switch. Can be driven from a cheap Rasberry Pi or any other low power mini PC.


15-20 years ago if you were using a cheap dedicated hosting company that stacked "servers" in desktop cases on wire racks and somehow offered instant remote reboots despite clearly being too cheap to buy switched PDUs, they were doing something just like this.


The more I work with MQTT the more I enjoy it. It's just enough protocol to get the job done without overcomplicating things. Nice work.


Crazy good ESPHome story here!

> I wanted a quick solution (with ideally no custom firmware development) and was already familiar with ESPHome, which turns out to very easily implement the functionality I wanted :)

> In addition to a standard ESPHome configuration, I have added the following lines to make the GPIO pin available through MQTT, and make it a momentary switch instead of a toggle switch, so that it briefly presses the power button and doesn’t hold the power button:

Really simple looking understandable yaml.file constitutes almost all the softwafe development done for this project. Stunning. Nice.


Few years ago I did the same thing with a raspberry pi zero W and two bash scripts - one for power on/off one for reset. It's quite useful to have and was born out of the need to reboot my Ryzen 1700x powered pc, due to p(ower)state bug that I only uncovered as the culprit a year ago.

Here's a simple writeup with pictures : https://1drv.ms/u/s!Au9Lr9dxN7gUs8AQo6pkvUxXb1DD4g?e=DCqDzG


I want this feature. Power cycle a machine from somewhere else. The smart PDU strips are suspiciously complicated and expensive enough that I don't want to discover I bought an unreliable one.

Current thinking is a relay held open by power over ethernet and toggle the switch port to reboot it, but I don't quite have the nerve to solder the relay myself. I can't deal with a dead/crashed switch remotely anyway.


If this is something permanent (and needs to be reliable), I'd advise the author to move it to perfboard/veroboard.


Nit: Please hyphenate "out-of-band". That's how it's usually written, and it's much more readable.


Now hyphenated, thanks for the hint


Keeping wake on LAN on will likely use less power than this ESP32 solution.


A mosfet seems pretty overkill for this instead of practically any cheaper transistor unless there’s something about motherboard headers I don’t know. Pretty cool though.


Cheaper transistors should totally work, as I tried to describe in the article.

I had this particular MOSFET lying around from a different project, so that’s the main reason I chose that one :)


It’s also only $0.46 in singles at DigiKey, so hardly something crazy wasteful in any event.


A no-thrills transistor would be some 2 cents, so 20 times cheaper on the other hand.


I wasn’t able to locate any suitable BJTs around $0.02 in single qty at DigiKey.


Why is the transistor needed at all? Does the current to turn on/off the machine exceed the ESP32's pins?


Because you need to act like a switch.


> void setup(){ pinMode(PWRBTN, INPUT); }

> void press(){ digitalWrite(PWRBTN, HIGH); delay(33); digitalWrite(PWRBTN, LOW); delay(33); digitalWrite(PWRBTN, HIGH); }

My 5min hack would look like this - and optionally a 0.1uF and a 1k resistor for peace of mind - totally untested though. Usually a uC I/O pin has three states; output high, output low and Hi-Z. Hi-Z is high-impedance or extremely high resistance state, analogous to an open circuit.


Right, just toggling a GPIO. From what I can tell, there is some claim of 5V 500mA for a short period when doing this, which would explain the transistor.


I mean, you can use a GPIO on a microcontroller as a switch if the current is small enough... this device is not directly in the path of 120V, it's just twiddling a GPIO on the motherboard... right?


We have a couple of sms enabled plugs for some remote places, worst comes to it we can send a txt and power cycle the devices




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: