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 uUSB 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 are also two extra common GNDs 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, 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 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 $ ./build
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
!! 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 very 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.
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. 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 sonn 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).
1. Start with the smallest part, the micro USB connector. Align it with the pads and hold it with a clip or helping hand. Solder one side pad, then continue to solder the rest of the pads. This may be challenging if you are not comfortable soldering SMT components:
2. Insert the resistors matching them with the silkscreen markings for their values. Use a resistor color code map if you need to. Spread their leads on the other side so they don’t fall out when you flip the PCB, then proceed to solder each joint. When done clip all the leads with a flush cutter:
3. Repeat for the rest of the larger parts, again spreading the leads to keep them from falling out when soldering. Make sure you match the large electrolytic capacitor negative lead (silver stripe on side) with the “-” on the PCB. Also match the silver stripe on the diode with the direction of the arrow (cathode). Also match the notch on the chip holder with the notch on the PCB silkscreen.
4. Gently bend the ATTiny microcontroller pins to make them parallel and insert them in the holder, making sure you match the notch on the holder/PCB with the pin marked with a dot:
5. Using a pair of pliers clip the male header into 3 headers: 1×2, 1×4, 1×6. Insert them one by one and hold them in place with your helping hand while soldering: