Before you get started it will help to familiarize yourself with these topics:
Download and unzip the software that will be used in this project from the following link:
Expected battery life:
750 mAh / 135 mA = 5.6 hours
Actual Battery Life:
The watchdog is configured as a timer to wake from sleep.
Inside the setup() function the watchdog control register is changed so the watchdog functions as a timer that fires interrupts instead of resetting the processor. The watchdog timer has a limited configuration of periods, so the maximum period of about 8 seconds is used for this example.
The Arduino is put into power-down sleep mode while sitting idle between measurements.
When the watchdog timer fires every 8 seconds the Arduino will be awakened from sleep. Once awake the Arduino increments a count and after it reaches 7 sleep iterations (roughly 56 seconds) a sensor measurement is logged. Finally, the Arduino is put back into sleep mode while it waits for the watchdog to wake it again.
The CC3000 is disabled while the Arduino is asleep.
In the setup() function communication with the CC3000 is initialized, and then the wlan_stop() function is called to put the CC3000 into a low power disabled state. When the Arduino awakes to take a measurement the CC3000 is enabled by calling wlan_start(), connects to the wireless network to send the measurement, and finally shuts down by calling wlan_stop() again.
Expected battery life:
775 mAh / 45 mA = 17.2 hours
Actual battery life:
Power LEDsTo reduce the power consumption I made the following changes to the hardware:
Both the Arduino Nano and CC3000 have small LEDs that constantly draw current through resistors. These LEDs are useful indicators when the hardware is connected to wall power, but when running on batteries they consume precious current. Looking at the CC3000 and Arduino Nano schematics, each LED pulls about 8-10 mA of current alone.
The linear voltage regulators on board the Arduino and CC3000 do their job well, but aren't particularly power efficient. Power regulators have a minimum current draw, their quiescent current, and the regulators on the Arduino and CC3000 have a quiescent current of about 5-10 mA each.
Photocell and Pull-up Resistors
The photocell and resistor in series with it, like the LEDs, are another source of constant power consumption. Even the pull-up resistor on the Arduino Nano's reset pin consumes a non-trivial amount of current, about 5 mA.
Switch to barebones Arduino using the ATmega328P processor on a breadboard.To build this example you will want to be familiar with how to build a breadboard Arduino. Be warned this is an advanced project that could be difficult for a beginner to build and troubleshoot. You will need the following parts:
By building my own Arduino on a breadboard I can upgrade and remove components compared to the stock Arduino board. With my custom built Arduino I removed the power LED, serial to USB communication chip, and switched to a larger 1 mega-ohm pull-up resistor on the reset pin to reduce current consumption.
Upgrade the voltage regulators.
I added much more power efficient LT1529 voltage regulators to provide the 5 volts and 3.3 volts required by the Arduino and CC3000 respectively. These regulators have a very low quiescent current of 0.05 mA. The regulators can also be shut down completely by pulling a shutdown pin low. This means the Arduino can shut off power to the CC3000 while it's asleep and ensure there's no unnecessary current draw from the CC3000 power LED.
One down side of these regulators are their cost; in single quantities they cost about $4-5. However their high current rating (3 amps) will make them useful to have for future projects. You don't need to use these exact regulators too--look for any 3.3 and 5 volt regulators that have low quiescent current and ideally a shut down pin.
Power the photocell/sensor only during measurements.
I made a small change to supply power to the photocell using a digital output of the Arduino instead of the 5V power regulator. This means I can control when power is applied to the photocell rather than it constantly drawing power. Small optimizations like this to control when sensors or other components in your hardware have power can add up to significant power savings.
Assemble the hardware as shown in the pictures and schematic to the left. Follow this guide on building and programming a breadboard Arduino for help. Build the Arduino first and verify it works with a blinking LED or other test program before moving on to add the CC3000 and its 3.3 volt regulator.
One important change to note is that the CC3000 is no longer powered on its VIN pin. The external 3.3 volt regulator will instead feed power into the 3.3V pin on the CC3000. Be very careful not to mix up wires and send 5 volts into this pin or you could damage the CC3000! Check voltages with a multimeter before hooking up the outputs of the voltage regulators to be sure they are what you expect.
Expected battery life:
775 mAh / 23.3 mA = 33.3 hours
Use higher capacity batteries.
Switching to AA rechargeable batteries with 1900 mAh of capacity would easily let the hardware run for over 3 days on a single charge. Lithium ion batteries with 4000 mAh capacity could run for about a week. A small lead acid battery with 10 amp-hours of capacity could run for over half a month! Check out this battery guide for more information on the types and capacities of different batteries.
Reduce measurement frequency.
Instead of recording a measurement every minute, increase the measurement frequency to every 10 minutes or more. The longer the measurement frequency, the more time the Arduino will stay in its low power sleep mode and reduce the average current consumption.
Using the measured current usage data you can estimate the new current consumption by solving the equation:
Ia = Current while awake = 133 mA
Is = Current while asleep = 0.9 mA
Sa = Seconds spent awake = 10 seconds
F = Measurement frequency = 600 seconds (10 minutes)
( Ia * Sa + Is * (F - Sa) ) / F = average current consumption at frequency F
( 133 * 10 + 0.9 * (600 - 10) ) / 600 = 3.1 mA average current consumption
With a 3.1 mA average current consumption the hardware could run for almost a month on 1900 mAh AA batteries!
Scavenge power with a solar cell.
Consider adding a solar cell to the hardware to charge the batteries while the Arduino is asleep. Check out this guide on solar cells and battery charging for more information. If there's enough light available your hardware could run indefinitely!