Turning the Pi On and Off – WeatherPi Solar Power

Turning the Pi On and Off – WeatherPi Solar Power Weather Station

What is WeatherPi?

SwitchDoc Labs is in the process of building a Solar Powered Raspberry Pi WeatherIMG_3171 Station.   The design will be released as a SwitchDoc Appnote, an Instructable and a series of posts on SwitchDoc.com.  We are right in the middle of finishing the wires inside of the weather proof box.

In this article, we are going to discuss the problem of powering down and up your Raspberry Pi.  In Solar Powered systems, this is called the “Brownout Problem”.  We will be showing how to use a simple device, the USB Power Control from SwitchDoc Labs to solve this problem.

Starting and Shutting Down Your Raspberry Pi Computer Reliably

 

IMG_3384
Weather Pi Sitting outside for the First Time (sans WeatherRack)

One of the most important issue in designing a Raspberry Pi Solar Power System is turning on and off.  The “Brownout Problem” is a real issue.  Why worry? If you have a long string of cloudy days, you may run your battery down. You can compensate for this in your design by adding more panels and more batteries, but that can get really expensive and your system might still run out of power, just a lot less frequently.

Shutting Off the Pi

Shutting a Raspberry Pi off is pretty easy. When the battery voltage falls below some value, you just do a “sudo shutdown -h now” and your Raspberry Pi will shutdown cleanly.  Our next article tells how to determine the battery voltage to shut down the Raspberry Pi.

Note that in most solar power systems, you need to monitor the battery voltage and not the 5V power supply because with most modern voltage booster systems, the circuitry will work very hard to keep the 5V going and then just give up crashing to a much lower voltage when it runs out of power.  Our next article will show you a method of determining the correct voltage to shutdown.  It will vary with your system design!

That means your computer would have little or no warning when the voltage is about to drop. By monitoring the battery voltage, you can tell when the battery is getting low enough and then shut down your computer safely. For LiPo batteries, this will be when your voltage gets down to about 3.5V or so. This can all be monitored with the SunAirPlus solar charge controller that we are using in WeatherPi.

Starting the Pi

Enough about shutting down the computer. What about starting it up?

The Issue

You can’t just let the controller power up the computer. The problem is that the supply voltage will move up and down until there is enough charge in the battery to fully supply the computer. When the computer turns on (connecting a full load), you will pull the battery down hard enough to brown out the computer causing the Raspberry Pi to crash. This constant rebooting cycle can corrupt and ruin your SD card and cause your computer to never boot at all, even when the power is restored.   We had this VERY thing happen to us 3500 miles away with Project Curacao.  Arduinos are more tolerant of this, but Raspberry Pi’s do not like a ill-behaved power supply. You just can’t be sure of what state the computer will power up at without a good power supply.

IMG_0275
Project Curacao Power Subsystem

This issue can be handled in a number of ways. The first is to use another computer (like an Arduino made to be very reliable by using a WatchDog – see the Reliable Computer series on switchdoc.com – https://www.switchdoc.com/2014/11/reliable-projects-watchdog-timers-raspberry-pi-arduinos/) to disconnect the Raspberry Pi’s power through a latching relay or MOSFET when there isn’t enough power. Project Curacao (https://www.switchdoc.com/project-curacao-introduction-part-1/) used this approach. The BatteryWatchDog in the block diagram to the right is an Arduino hooked up to an external SwitchDoc Labs Dual WatchDog Timer board.

 


 

 

Power Your Pi Up and Down with the USB Power Control

A second (and cheaper!) way  of handling the brownout and power up problem is to use a dedicated power controller that will shut the power off to the

SunAir Power Controller Manufacturing Prototype
USB Power Controller

Raspberry Pi and restore the power when the battery voltage is high enough to avoid ratcheting the supply voltage up and down because of the load of the Raspberry Pi.  This is called Hysteresis.  We have designed a board to do just this (called the USB Power Controller) that will plug between the USB coming out of the SunAir Solar Power Controller and the Raspberry Pi as in the picture to the right.

The USB Power Controller

USB PowerControl Application Diagram
USB PowerControl Application Diagram

The USB PowerControl board is a USB to USB solid state relay.  It is is a digitally controlled power switch for your Arduino or Raspberry Pi.  It is a Pi On and Off switch.

Anything you can plug into a USB port can be controlled with USB PowerControl. It’s easy to hook up. You connect a control line (a GPIO line or the output of a LiPo battery) to the LIPOBATIN line on the USB Power Control device and if the line is LOW (< ~3.3V) the USB Port is off. If it is HIGH (above 3.8V) the USB Port is turned on and you have 5V of power to the USB plug.

This board was initially designed to sit in-between a Solar Power Controller (such as SunAir/SunAirPlus) and a Raspberry Pi / Arduino. The input to the board was designed to come directly from a LiPo battery so the computer won’t be turned on until the LiPo battery was charged up above ~ 3.8V.  We provide a hysteresis circuit so the board won’t turn on and then turn immediately off because the power supply is yanked down when the computer turns on (putting a load not the battery).  This really happens!!!!  You kill Raspberry Pi SD Cards this way.

There is little software for this device. You connect it directly to your LiPo battery for automatic control!  The only software used detects the battery voltage and decides when to shut down the computer.  The USB Power Control takes care of shutting the power to the Raspberry Pi when the battery voltage gets low enough.  Note that a shutdown Raspberry Pi still draws current (according to one quick measurement, about 100ma).

 Next Up

Our next article will show how to determine the turn off (time to shutdown the Raspberry Pi cleanly!) voltage on the battery in the WeatherPi.  We basically 1) Charge the battery and then 2) Discharge the battery until the Raspberry Pi quits.  Add about 0.2V to that value and you have turn off voltage.  The turn on voltage is handled by the USB Power Control.

Updated Parts List (April 11, 2015)

Block Diagram

IMG_0876