This text specifically refers to the v1.0 boards. The files are all available on GitHub.
In order to make my RasPi MPD server more “living room” (read as you will…) and user friendly, it really needs to have a proper controlled power on/off switch. Additionally, it’s not good for the integrity of the SD card to have a slow switch off, which you get from turning off a normal supply or from trying to pull the lead out. Ideally, the system should be shutdown in software first, and then have the power removed. There are a two other projects which appear to do the same thing (by no means exhaustive!), but they also end up with more cables. Everyone using a RasPi surely already has too many cables..!
In order to do both for a small system, the Pi2RMini fits onto the GPIO header directly. There’s a switch and bicolour status LED onboard to control, so there’s no need for any wires if you don’t want them. Power connections are the usual micro USB B, or provision for a direct input potentially from a higher power supply. The power input can by fused with a resettable/non-resettable fuse depending on preference. Power to the RasPi is through a P-channel MOSFET acting as a switch, so only dissipating P = IRPi2Rds from a small SOT-23. The N-channel MOSFET is there to ensure the gate of the P-channel is switched fully off at 5V, rather than the 3.3V the microcontroller is at. As the board powers the GPIO header directly, it’s prudent to fit a polyfuse in F1 so there is some protection for the RasPi.
The board could be smaller, however it I wanted to keep it reasonably sized so people could build it themselves, and also it provides some mechanical support with the screw, useful if the power flex is heavy. The standard 6-pin AVR programming header is in the centre. If you are mounted in a case, the switch and bicolour LED are broken out on a separate header. The board is very easy to build up (trickiest is the USB header), and would actually be a good first SMD project. It’s also single layer, so you can etch it easily at home. I’ve included a correctly scaled PDF of the copper.
Bare and built boards. Prototypes so a little rough around the edges with parts that were available etc.
Jumper is for the LED: schematic is for a common anode, only had common cathodes. Two resistors at F1 will be a polyfuse.
Mounted on a RevB Raspberry Pi.
Side view mounted on board.
On the RasPi side, there’s a small script that runs in the background and checks for signals on the GPIO 7 pin and communicates (very simply) back to the Pi2RMini. On power up, the Pi2RMini will wait 20 seconds for a response from the RasPi; if this is not met, it will go into error mode (LED flashing red) awaiting a hard reset. When a signal to shutdown is received from the Pi2RMini, the script issues
sudo shutdown -h now
to shut the system down cleanly. The Pi2RMini will pause for 20 seconds after receiving acknowledgement of the shutdown signal and then switch off power to the RasPi. If no confirmation is received from the RasPi, the Pi2RMini will go into error mode (LED flashing red), and will require a complete reset. Pushing the button when the system is on for longer than 4 s (the LED will flash green then red continuously) will lead to a reset, and cut off power completely and instantly. It’s important to note, that this is less likely to corrupt your SD card than simply pulling the cord out, as the MOSFET switch-off is very quick. All the timings are easily altered in the firmware and flashed to the board. The code (I think!) is well commented, so it should be fairly obvious. There is approximately 47% of the flash space left on the ATTiny13, so there’s plenty of room for modifications – it would be great to see some!
To get the board up and running, you will need to run the following commands from your home directory:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install github
git clone git://git.drogon.net/wiringPi
sudo chmod 755 pi2rmonitor
In order, this updates your RasPi and installs GitHub (steps 1-3), then installs wiringPi (steps 4-6), then gets the RasPi script for the Pi2RMini and changes it to executable. Finally, you need to add the following line to /etc/rc.local just before the final line (exit 0). This will start up the script when you first start your RasPi, so you don’t have to start the script up manually each time.
(cd /home/pi && exec ./pi2rmonitor) &
- Changes.txt contains a summary of completed and future changes
- Pi2RMini v1.0.brd Layout in Eagle format, v6.1.0
- Pi2RMini v1.0.sch Schematic in Eagle format, v6.1.0
- Pi2RMini v1.0.pdf Processed and properly scaled PDF for those wanting to etch their own boards. Not mirrored.
- bom.xlsx full BOM, including Farnell part codes. These are for 100 quantities, approximately multiply by 2.5 to get the unit price. Total price is quoted for the Farnell parts, inclusive and exclusive of VAT. Not up to date with latest prices, only up to last modified date.
- Pi2RMini.c Written in AVR GCC using AVR Studio v5. The compiled release binary is pi2rmini.elf and pi2rmini.hex
Released as free, open-source hardware. All the files are available to download from GitHub. Free to use, modify, and distribute. I will be offering these as the v1.1 board with some modifications as both kits and fully constructed in the near future. This will, of course, also be free, open-source hardware. Please subscribe to be kept up to date!