- What is it?
- Mike’s Rev1 review
- Installation and source code
- Possible/known issues
- Fuse option
- Rev1 details
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.
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.
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:
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:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install git-core
Download WiringPi from github and build it:
$ git clone git://git.drogon.net/wiringPi
$ cd wiringPi
2. Copy the shutdowncheck bash script to your home directory – /home/pi/ and add the proper execute rights:
$ cd ~
$ wget https://raw.github.com/LowPowerLab/ATX-Raspi/master/shutdowncheck
$ sudo chmod 755 shutdowncheck
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):
The shutdown script will take on average 0.7% of the CPU:
- 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:
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:
!! 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.
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).
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:
Rev1 details: Click here to see details about ATXRaspi R1