Raspberry Pi is a great platform to be used in a robot project, but it has a severe limitation: by default it does not have a built-in power button. As a Linux-based system Raspberry Pi requires to be shut down gracefully before switchin off power. Simply plugging the power cord off may corrupt the file system on the SD card, which I have experienced too many times. To avoid corrupting the file system we constructed a simple circuit for shutting down power gracefully. The circuit also allows us to put our robot into sleep mode, automatically waking up the robot after specified time interval. Just out of curiosity we added possibility for measuring current consumption. Some commercial solutions such as Sleepy Pi with similar functionality do exist, but this kind of system is quite easy to construct from separate components.
Feeling sleepy?
Since I started constructing our robot it was obvious that the operating time is going to be quite limited by battery capacity and power consumption. If there is nothing particularly interesting going on, the robot could extend battery life simply by shutting itself down. This would require some kind of alarm clock for waking the robot occasionally up to check if there are tasks that should be executed. For our robot boat this kind of functionality would allow traversing long distances for example by drifting freely with wind, perhaps with aid of some kind of sails.
Our shut-down circuit is composed of following parts:
Pololu Pushbutton Power Switch is a nice product: a simple push-button can be used to switch power on and off without using a relay. The attached button does not need to be pushed physically: external circuit such as Raspberry Pi or a microcontroller can be used to turn the power off by providing a positive voltage to the Off pin. The switch can tolerate 10 amps of current, so it is sufficient for powering Raspberry Pi and lots of peripherals.
Pololu 5V, 9A Step-Down Voltage Regulator D24V90F5
The step-down voltage regulator is used to reduce 12 volts down to 5 volts for powering the RasPi. Again, the regulator contains an Enable pin, which can be pulled low by external hardware for shutting down power. The enable pin is pulled up to 12 volts using internal pull-up resistor, so it cannot be connected directly to Raspberry Pi which operates on 3.3 volts. Thus, a transistor or or a fet is required in the circuit.
For more detail: Raspberry Pi Shutdown Circuit with Sleep mode