Now that the software part of my project is done I’m moving on to the prototyping stage. I’m beginning by testing a couple of the components I purchased. The first is this powered USB hub. In addition to allowing me attach more devices to my Pi it can also power it. This will allow me to run a single power line into my case rather than two (one of the Pi and a second for a powered hub).
I plugged it in and it worked just fine. It successfully powered the Pi and the Pi was able to recognize devices I plugged into the hub.
The next item to test is my shutdown circuit. As anyone who has used a Raspberry Pi is aware it does not have a power button. To power it on you plug in a power source. Shutting it down is a bit more complex though since you have to send a shutdown signal to the OS and allow it to power down before removing the power. I don’t want to deal with that process once I get the Pi installed in my case so I ordered this shutdown switch from Mausberry Circuits. This circuit sits in between the power source and the Pi and connects to an external switch. When the switch is closed the circuit passes the power along to the Pi which allows it to boot. When the switch is opened the circuit sends a shutdown signal to the Pi via GPIO which tells it to shut down the OS. Once the shutdown process is complete the circuit removes power from the Pi. Ultimately I want to attach this circuit to my Dreamcast case’s power switch but for now I’ll just test it by wiring it to a breadboard.
Before I actually wire up the circuit I need to install the program that will watch the GPIO for the circuit’s shutdown signal. Mausberry Circuits provides a bash script that will do this using a while loop to pole the GPIO. However, I’ve heard some complaints that this continuously running loop can steal system resources. After some research I ran across this Python program. It is programmed to wait for the shutdown signal from the GPIO rather than polling the GPIO constantly to see if the signal has been sent.
I’ve installed the program and wired up the circuit. It’s time to test it.
And it works! When I close the switch the Pi boots. When I open the switch the shutdown signal is being interpreted correctly and power is removed when the shutdown is complete.
Two of the main items I chose to run my project are working like I wanted. Time to move on to the next step.