ATXRaspi

What is it?

ATXRaspi is a smart power controller for RaspberryPi or similar embedded systems running from a 5V input. It allows you to have an external shutdown button to turn off your target system without a need to login or to issue manual shutdown/sudo halt commands. Here’s a nice example of how a user integrated ATXRaspi in a home media center.

compared2_small

To keep costs low, embedded systems like RaspberryPi don’t usually have a shutdown button like desktop computers, so to avoid potential issues when shutting power off you have to log in and issue a shutdown command instead of just pulling the power cord. This is sometimes inconvenient when your Pi  is not easily accesible or you don’t have network access to it, and even if you do it’s sort of a pain to always have to login just to do a shutdown or restart. Or maybe you have a product based on RaspberryPi or a similar embedded system and you’d like to offer your customers the ability to gracefully shutdown without having to first login. ATXRaspi solves this problem by allowing you to have an ATX style shutdown button that will issue a shutdown signal to RaspberryPi for you.

To turn ON the Pi all you have to do is press the power button. To trigger a shutdown to the Pi you have to hold the button pressed for ~4 seconds (the delay is there to avoid accidental shutdown). A shutdown sequence then begins. While a shutdown is in progress the LED will pulse at a slower rate. When shutdown is complete, the LED pulses faster waiting for all Pi activity to stop and finally cuts power off.
There is also a “Forced-Shutdown” mode that requires you have to hold the button pressed for about ~10 seconds to cutoff power regardless of any other conditions. This may be needed when the Pi is in an unknown state or has freezed.

Diagram

diagram_inkscape_12_OUT_small

You have the option to feed power through a micro-USB as you normally would to the RaspberryPi, or through a standard spaced header.

The top header has connections for the power button and an LED that will be ON while power is ON, and will fade in and out while shutdown is in progress. The output header has INPUT and OUTPUT signals that connect with the Pi’s GPIO, and of course the power OUTPUT to the Pi. There 2x 5V and 3xGND outputs, and four standard mounting holes.

When the button is pressed the first time the LED turns ON and power will flow from INPUT to OUTPUT and turn the RaspberryPi ON. The top INPUT signal is turned HIGH by RaspberryPi by a script. This is how ATXRaspi knows that the Pi has successfully booted. The OUTPUT signal is turned HIGH when ATXRaspi is asking RaspberryPi to shutdown. Another script is running on the Pi and listening on this pin.

ATXRaspi also works as a power controller for other similar embedded systems that have a 5V power input.

Mike from mikesmicromania.com has put together a review/demo on ATX-Raspi R1, thanks Mike. Here’s his setup:

Installation guide and source code

First things first:

! IMPORTANT ! To ensure stability you will need a good power supply (as recommended for it anyway), at least a 5V 1A power supply to power the ATXRaspi. This is to avoid any voltage drops when you turn power on to your RaspberryPi and consequently cause ATXRaspi to loose power.

! MORE IMPORTANT ! Make sure you DO NOT plug in power to the RaspberryPi directly/separately while ATXRaspi is connected. This might cause damage to any of the boards involved.

1. Install the WiringPi library (I installed mine from the /home/pi directory).
This library gives you easy access to RaspberryPi’s GPIO.

First install git if you don’t have it installed:

Download WiringPi from github and build it:

2. Copy the shutdowncheck bash script to your home directory – /home/pi/ and add the proper execute rights:

The script is located at: https://github.com/LowPowerLab/ATX-Raspi/blob/master/shutdowncheck

NOTE: Someone reported some corruption when copying the scripts from github. This is not apparent because newlines are interpreted differently on different OSes. If you experience problems with the script not running or generating errors, try typing the script yourself using “sudo nano schutdowncheck”.

3. Edit your /etc/rc.local file (sudo nano /etc/rc.local) and add the following line before the last line (exit 0):

(cd /home/pi && exec ./shutdowncheck) &

This should start the shutdowncheck script during initial booting and you should see these messages towards the end of the Pi’s startup (if you’re not booting to the GUI):

ATXRaspi shutdown script starting…
Asserting pins (7=in,low; 8=out,high)

The shutdown script will take on average 0.7% of the CPU:

CPU_percent

That indicates the script has started and is running, waiting for a shutdown signal from ATXRaspi.
4. Connect your RaspberryPi to ATXRaspi. But remember: make sure the RaspberryPi is disconnected from power since ATXRaspi will power your Pi. The given GPIO pins are given as examples, you may change them to others as convenient (update the script as well), or if you have a Rev 2.0 Pi you can use the P5 header instead. Here’s how I wired ATXRaspi:
  • GPIO7 (input to Pi) to outgoing arrow pin on ATXRaspi.
  • GPIO8 (output from Pi) goes to incoming arrow pin on ATXRaspi.
  • Connect power from output header (+/-) of ATXRaspi to GPIO power pins (5V/GND) on RaspberryPi
  • Connect a momentary button and status LED to ATXRaspi’s top header (no resistor needed for LED).

When done, the wiring should look something like this:

USB_power3

Or if you have Rev1 or just powering through the header, you can use jumper wire to connect to 5V/GND on the Pi GPIO header:

ATXRaspi_wiring_to_RaspberryPi!! NOTE !! You should use good quality wires (especially for the power signals), ideally stranded and not longer than 6 inch. They should make tight/strong connections with the headers on both ends. This is important because at startup the Pi will draw a lot of current for a short period of time. If the wires cannot handle the inrush of current, a drop in voltage might occur, causing ATXRaspi to reset and power to be cut-off from the Pi. The symptom will be this: you will press the button, power is turned on for an instant, then turned off, and may require several button presses before power will stay on. This is more important on Rev1; Rev2 should be more stable because it’s using a mosfet instead of a relay, but still worth to consider.

5. Done!

Possible/known issues

1. Need to push button a few times before power up. This could happen for several reasons. Rev 2.0 Pis are more prominent to having this issue. You should not really see this on ATXRaspi Rev2, especially if you power through the USB-A output power option. If it still happens, a few things will help eliminate such behavior:

  • using a good power supply that will handle the big current spike at power-up. In other words a supply that will not drop voltage significantly upon the power-up current surge. Phone charger type supplies tend to be flaky, unless you got good brand ones rated at 0.8-1Amp.
  • using a ferrite bead around the + supply line going into the Pi (also see Mike’s video above). This helps with the inrush of current or possible harmonics introduced by high energy spikes when the Pi starts up. Wrap the + wire through a ferrite bead several times, that will increase the inductance and slow down the current, avoiding a big voltage drop
  • using heftier jumper wires for the power lines going to the Pi
  • soldering the wires to your Pi (Mike did it in his setup using the P5 header)

2. Disconnecting ATXRaspi and powering up the Pi directly will cause it to shutdown soon after boot up. This is because the signal ATXRaspi was using is setup as an input without a pull-up/pulldown resistor which might be floating and be picked up by the shutdowncheck script. To eliminate this problem – comment out or remove the line you added in the /etc/rc.local file before you disconnect ATXRaspi (otherwise you might not have another chance to do it with ATXRaspi disconnected – because of repeated shutdowns).

Fuse option

There is now the option to add a fuse directly on ATXRaspi, by cutting this trace and soldering your fuse of choice on thep provided footprint:

fuse_circled

Rev1 details: Click here to see details about ATXRaspi R1

DSC02674_

Outline/dimension diagram

ATXRaspi_R2_Outline_dimensions

22 thoughts on “ATXRaspi

  1. DUDE!! Love the new option on Raspi V2! Couple questions: 1st, On the Female A port option does the male plate go top or bottom? 2nd, on the 2.1 input option is that 5.5/2.1?
    I asks because as opposed to an A to micro cable, I’d like to use something like this http://dx.com/p/usb-to-micro-usb-adapter-58818

    • The USB is soldered on top as seen in pictures, it’s a standard connector, The adapter you linked looks like would work, but I’m unsure if both boards would be face up. I think the burden is on the connector you use. That’s why I offer the cable and not a straight through adapter like the one you linked.

  2. First I wanted to say thanks for this device. I got my copy yesterday and it’s great. I’m having two issues, however, and I’m hoping you can help me. I’m using the same button switch with the led circle in it that you have in the video and on your site. I can turn on the device fine, with the button wired to NO.

    #1. Upon bootup, the led labelled shutdown on the board lights up, rather than the bootup led. I don’t understand this, because I must have the two signal cables wired correctly otherwise it wouldn’t boot when I turn the switch on.

    #2. It always takes three pushes of the buttons to turn it off. Only on the third push will it begin the shutdown sequence. I’ve tried holding it for 4 seconds as I read on the site, but that didn’t help.

    Any advice?

    • #1 – that is normal, actually the silkscreen label for Shutdown and BootOK are sort of misplaced or reversed, I will fix that in the next batch.
      #2 – that is not normal, as long as you have a functional button, and the BOTTOM smd LED is ON (turned by the Pi script), the top LED should come ON after ~4sec of pressing the button and the status LED should start pulsing, signalling a shutdown has been requested, etc.

  3. Hi Felix, I received my ATXRaspi yesterday (very prompt shipping thank you) and had it all wired up with pins soldered with in in an hour. Just wanted to say thanks it is an amazing little piece of kit and the instruction on the site are perfect. I am having one small problem though but not at your end. The shutdowncheck script will not run from the rc.local at start-up. I am using the standard ras-pi debian wheezy all updated as per the instructions above. I am a novice with Linux so its probably something I am missing but any advice would be very welcome. Once again thanks for all your effort

    Gary

    • Hey Gary, thanks for the feedback! I also use debian wheezey without issues, have you checked that you have all steps done/ What is the output you see from rc.local? The script should dump the following messages to the terminal:
      echo “ATXRaspi shutdown script starting…”
      echo “Asserting pins (7=in,low; 8=out,high)”

      Can you check if the script runs at all?

      • Hi Felix, thanks for the quick response I have it sorted out now. I commented out a couple of lines which seem to have done the trick. They were there to display the ip address which wasn’t working anyway but my fantastic power switch is now. Once again great work, thanks! Gary

  4. Hi Felix, I have been reading about your ATXRaspi board and I have a question. If you send a reboot command to the Raspberry Pi, does it complete the reboot or, instead, the ATXRaspi turns off the RPi when it is starting the reboot?

    Thanks

    • A software reboot does not interfere at all with ATXRaspi or vice versa. Power will be kept ON, so the reboot should restart the Pi as usual.

      • I have tested the shutdowncheck script (modified to use gpio 30 and 31 from P5 connector). After sending a shutdown command, the RPi goes off and voltage at output pin 8 (30 in my case) is zero.

        But if I send a reboot command, and I continuosly measure the output pin, just when the RPi turns off and restart, the output pin 8 is at zero voltage during many seconds.

        I suppose that ATXRaspi reads this transition to low from output pin and then turns off the power supply to the RPi. How can the board understand if the RPi has gone off or if it is rebooting, as output pin is zero in both situations.

        Thanks

        • You need to have an ATXRaspi connected for the shutdowncheck script to work properly. ATXRaspi pulls down the “shutdown” signal, if the shutdowncheck script detects a HIGH on that line it will HALT your Pi.

          • In your last comment, you talk about the ATXRaspi output, which is used to shutdown the Rpi after a button press.

            I refer to the other direction: the signal that the RPi sends to the ATXRaspi to inform that it is turned off. I mean that the ATXRaspi is listening for a low level in this line in order to switch off the mosfet when Rpi finishes its shutdown.

            Whatever it does, shutdown or a reboot, this line shows for a while a zero level, so I wonder how the ATXRaspi can distinguish among a reboot or a shutdown, because if it is a shutdown, the ATXRaspi has to switch off the mosfet and if it is a reboot, the switch must be on all time.

          • Too long of a story to tell here, i think i beat this horse to death. The point is, without an ATXRaspi, it’s pointless to debug the script and wonder why it doesn’t work. ATXRaspi doesn’t care about reboots, reboot all you want, ATXRaspi will keep power ON.

    • Can it handle it? It’s “5V” so it should be fine, but I would not put anywhere near 4amps through an ATXRaspi, I would recommend not sucking more than 1 amp, I cannot support extreme cases.

  5. Does anyone know if this will work with a Beaglebone Black? That is, will it make it enter sleep mode, and yield power savings?

    • ATXRaspi is a power controller not a sleep controller. Haven’t actually tested it with BB but if it can use a pair of GPIO pins for signalling it should work just fine.

  6. Two atxraspis arrived today in germany :-) Didn´t try them yet, but packaging was really good and professional! Thank you very much! Looking forward to integrate one of them into my media streamer… :-)

  7. Are there any cases for these boards? Are the schematics listed above current for the rev 2 board? Just curious as I want to make this blend in well and am going to try and get someone to 3d printer a case for me.

    Thanks.

  8. Pingback: ATXRaspi – Smart Power Controller for RPi @RaspberryPi #piday #raspberrypi « adafruit industries blog

Comments are closed.