Tutorial: Reducing Your Power For Solar
Designing Small Solar Power Systems is always a challenge. We always have a balance between the amount of hardware we want to power, how much power these devices use and the cost and expense (and often physical size) of the Solar Panels.
How much generating power does your Solar Power System need? That depends on a number of issues. We recently wrote an article on just that for our Solar Powered GroveWeatherPi product.
What is the GrovePowerSave?
The GrovePowerSave switches the VDD line of the attached (to the Out Port) Grove device. This removes power from the attached device, thus reducing the power the device consumes. The GrovePowerSave is controlled by a GPIO line from the Raspberry Pi or Arduino device and uses Grove Connections. (Using Pin Headers? See this posting). Specifications and how to use the GrovePowerSave are given here on the product page.
What is the USB PowerControl?
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. You can even use it as a Raspberry 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 and is controlled by a Grove connector with two signals, ENABLE and CONTROL.
The Grove Digital Input that allows you to control the USB PowerControlV2 using two GPIO Lines (one enable and one control line) to switch on and off from a Grove Digital Port. The Grove Enable Line, when high, disables the LIPOBATIN line and makes control of the device under the Grove Control Line. When the Grove Enable Line is low, the LIPOBATIN line controls the relay as in the original USB PowerControl. The Grove Enable Line is pulled down by a 43K resistor so if it is disconnected, the USB PowerControlV2 is compatible with the original USB PowerControl. LIPOBATIN is not used in the application. It is generally used to sense LiPo battery voltage and shut the USB PowerControl off and on using a hysteresis circuit.
The USB PowerControl defaults to ON, while the USB PowerControlNE defaults to OFF.
Project Curacao2 Power Measurements
We are using three Grove PowerSaves, one Grove PowerDrive and one USB PowerControl to manage power requirements in the Project Curacao2 design. The first thing to do was determine how much current could we save by shutting of device. We measured these currents by shutting devices off one by one and looking at the total system current and subtracting that from the initial power on current. Using the INA3221 onboard SunAirPlus, we measure 422mA as the starting power
Device Current Consumption in Project Curacao2 | |||
Device | Comment |
Current Consumed |
Control Device Used |
Grove Air Quality Sensor | Samples taken once an hour, 2 minute warm up time |
48mA |
Grove PowerSave |
LoRa WXLink and Arduino | Still deciding on timing. 15 minute an hour? |
75mA |
Grove PowerSave |
Grove OLED Display | Only used when someone is looking at the unit, which is not often |
25mA |
Grove PowerSave |
5V Ventilation Fan (also for Air Quality Sensor) | Used when to box is really hot (above 100F) and when running Air Quality Sample |
50mA |
Grove PowerDrive |
WiFi USB Dongle | Turn on WiFi from 10 before the hour until 10 after the hour. If someone is logged in, then don’t turn off |
80mA |
USB PowerControl |
Total Possible Savings: | All Devices Turned Off |
280mA Savings |
When the system powers up, all devices default to on. The first thing the Project Curacao2 software does is shut off the power to the devices that it doesn’t need immediately (Air Quality Sensor, 5V Fan, OLED Display). It leaves the LoRa WXLink system running as well as the WiFi USB Dongle.
Using these power saving devices allows us to cut 67% of the power consumption of Project Curacao (422mA down to 142mA), making our battery power last about twice as long more (why the difference? These devices do run some during each hour, cutting down the overall power saving).
Using GrovePowerSave to turn Grove Devices Off
To use a GrovePowerSave, you place the GrovePowerSave between the computer (Raspberry Pi, Arduino, etc.) and the Grove device.
1) You plug the incoming Grove Cable into the “In” Grove Connector on the GrovePowerSave (from the Pi2Grover for example).
2) You plug a Grove Cable into the “Out” Grove Connector on the GrovePowerSave to the Grove Device you want to control the power for (the Air Quality Sensor for example).
3) You plug a Grove Cable fromt he “Control” Grove Connector to a GPIO pin on the Raspberry Pi or Arduino (D4 in our example software).
Now you can control your device. The GrovePowerSave powers up in an “On” condition until you have set up your GPIO pins.
The basic software to do this (in Python) follows:
import SDL_Pi_GrovePowerSave import time GPIO_Pin_PowerSave = 4 myPowerSave = SDL_Pi_GrovePowerSave.SDL_Pi_GrovePowerSave(GPIO_Pin_PowerSave, True) print "turning Pin %i off" % GPIO_Pin_PowerSave myPowerSave.turnOffPowerSave()
Using GrovePowerSave to Reboot Grove Units (and Arduino’s)
When you are using complex devices in a design, there is a possibility that the devices may hang or become unresponsive. This is especially true in a Solar Powered system where there may be power issues or glitches on occasion. We also have noticed that complex devices such as wireless modulators and transmitters sometime hang. Some devices have reset lines that can be driven by GPIO lines, but others don’t. Also, in certain cases, a reset may not give the results you want. In that case you have to do a Power On Reset (POR). Our WXLink LoRa device (specifically the LoRa transmitter) can, on rare occasions, become unresponsive. The Arduino is also known to hang up on an I2C transfer on very rare events. We fix that by doing a POR using the GrovePowerSave on the Grove Connector powering the WXLink Arduino (the I2C connector from the Raspberry Pi).
The software is very similar to just turning off the device.
import SDL_Pi_GrovePowerSave import time GPIO_Pin_PowerSave = 4 myPowerSave = SDL_Pi_GrovePowerSave.SDL_Pi_GrovePowerSave(GPIO_Pin_PowerSave, True) print "turning Pin %i off" % GPIO_Pin_PowerSave myPowerSave.turnOffPowerSave() # sleep to provide good power on result time.sleep(1.0) #reboot device (POR) myPowerSave.turnOnPowerSave() print "turning Pin %i on" % GPIO_Pin_PowerSave
Using GrovePowerDrive to Drive (and shut off) a 5V Fan
We use a small 5V fan on Project Curacao2 to drive new air samples in for the AirQuality Sensor (and no, we aren’t sure this will work well. We need to run some experiments) and to provide some air circulation when the box gets too warm. We are using the GrovePowerDrive to provide the necessary current (~50mA) through the GPIO lines. The GrovePowerDrive puts buffers on the GPIO lines to provide high current outputs (up to ~100mA) out the Grove Connector Outputs (Sig1 and Sig2 – see our Grove Tutorial).
We wire up the fan + line to Sig1 using a Grove to Male Pin Header Converter and also wire up the ground on the fan to the ground connection on the Grove Connector.
The GrovePowerDrive software is similar to the software used for the GrovePowerSave:
import SDL_Pi_GrovePowerDrive import time GPIO_Pin_PowerDrive_Sig1 = 4 GPIO_Pin_PowerDrive_Sig2 = 5 myPowerDrive = SDL_Pi_GrovePowerDrive.SDL_Pi_GrovePowerDrive(GPIO_Pin_PowerDrive_Sig1, GPIO_Pin_PowerDrive_Sig2, True, True) print "turning Pin %i off" % GPIO_Pin_PowerDrive_Sig1 myPowerDrive.turnOffPowerDrive(1) time.sleep(60) myPowerDrive.turnOffPowerDrive(2) print "turning Pin %i off" % GPIO_Pin_PowerDrive_Sig2 time.sleep(60) print "turning Pin %i on" % GPIO_Pin_PowerDrive_Sig1 myPowerDrive.turnOffPowerDrive(1)
Note: We could have used a GrovePowerSave to do the same thing, but the GrovePowerDrive is a less expensive device and is well suited to this purpose.
Using USB PowerControl to turn the WiFi Dongle Off
One of the issues with WiFi dongles on the Raspberry Pi is that there is no real way of completely shutting them off. There are low power modes available on some Wifi dongles, but they aren’t reliable, don’t work on some of them and don’t reduce the current very much (they are still monitoring the network in most cases). When Project Curacao2 is deployed, we are planning to have the WiFi (for remote connections) be active for 10 minutes before the hour and 10 minutes after the hour, and possibly shut it off entirely during the night. If Project Curacao2 decides that it needs to send information when the WiFi is off (like in the case of detecting Lightning), it can turn it on, wait for power up (~30 or 40 seconds), transmit and then shut off again. All of this sounds like a hassle, but it saves 80mA, which is a substantial amount of current, especially at night.
The software for controlling this is simple, although we are in the process of writing a new Python Library to provide these functions on the USB PowerControl to make it similar to the GrovePowerSave.
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) USBPowerControl_PinControl=20 USBPowerControl_PinEnable=21 print "Default WiFi Device On" GPIO.setup(USBPowerControl_PinEnable, GPIO.OUT, initial=False) GPIO.setup(USBPowerControl_PinControl, GPIO.OUT, initial=True) print "WiFi Dongle Device Off" GPIO.output(USBPowerControl_PinEnable, True) GPIO.output(USBPowerControl_PinControl, False) time.sleep(20.0) print "WiFi Dongle Device On" GPIO.output(USBPowerControl_PinControl, True)
Summary
When designing a small Solar Powered system, there are always questions on how to reduce the power (and yes, we could pop a bunch of LEDs from the system to get another 20mA or so, but we like the lights, especially during debug and design) and to improve reliability. Using these devices to shut power down to system pieces that are aren’t needed all the time can provide significant power benefits. Having a way to reset devices (POR) is also very useful when dealing with inexpensive components.