There are some components on the datalogger that can pull a significant amount of current even while the Arduino is asleep:
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.
Breadboard Arduino parts:
- ATmega328P processor.
- Make sure to get the P version because it supports more power efficient sleep modes than the standard ATmega328 processor.
- 16 mhz crystal or resonator.
- 2x 22 picofarad ceramic capacitors.
- Small momentary pushbutton for the reset switch.
- 1 mega-ohm resistor to pull the processor reset pin high.
- Arduino programmer to load the Arduino bootloader on the ATmega chip.
- You won't need this programmer if you buy an ATmega328P that is already programmed with the Arduino bootloader.
- FTDI serial to USB cable to communicate with and load sketches on the Arduino.
Upgraded voltage regulator parts:
- An LT1529-3.3 and LT1529-5 voltage regulator, in the TO-220 5 pin package.
- Unfortunately these chips won't directly plug in to the breadboard so you'll need to carefully bend the pins to fit. Use pliers and bend as few times as possible to reduce the chance of breaking them.
- 2x 22 microfarad capacitors.
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.
- REG_SHUTDOWN_PIN should be set to the digital pin which is connected to the LT1529-3.3 regulator shutdown pin.
- SENSOR_POWER_PIN should be set to the digital pin which is connected to the photocell for power.
- When the Arduino wakes up or sleeps the CC3000 it also turns on and off the 3.3 volt regulator by pulling its shutdown pin low or high (low is shutdown, high is enabled).
- The sensor power pin is set high right before reading a measurement and then pulled low again. This powers the photocell only when necessary to take a reading.
- Before entering sleep mode a few registors are updated to disable the ATmega processor brown-out detection circuitry while asleep. This step slightly reduces the power consumption of the Arduino while it's asleep.
At full power during measurement send the current consumption is slightly reduced to 132 mA. In total the average current consumption of this example is only about 23.3 mA.
For this test I will again use the same AAA Ni-MH batteries as previous tests, and assume they have a 775 mAh capacity like in the last example.
Expected battery life:
775 mAh / 23.3 mA = 33.3 hours
This is a good case where the watchdog's normal reset functionality could be useful. If the code gets stuck in a loop the watchdog can reset the unresponsive hardware and prevent it from staying in a constant high power state. However because the watchdog is also used as a timer to wake from sleep, care would need to be taken to use the watchdog as a reset when awake and as a wake up timer when asleep.
Without the connection issues the curve of battery life looks like it was on a path to hit at least 30 hours. However with the issues encountered, the actual battery life in this test was 28 hours.
What do you do when you want to run even longer on batteries? Some options to increase the runtime of the project are:
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!