Sleep time and battery saving adjustments

I have been working on a remote water pressure measuring device that needs battery life optimisation.
It uses Aruino UNO, a MPX2010DP differential pressure transducer. I power the thing with a 12V 1.2 Ah lead-acid sealed rechargable battery and it only lasts about 5 days =(.
I used the Todd Houstein code for this (https://sites.google.com/site/toddsstuffnthat/arduino-code-1/DataLogger.pde?attredirects=0&d=1)

I need to log data roughly every 1, 10, 60 min and 24 hrs in some cases.

Looking into the code and the debugging in the serial I found that the longest sleep time for the Arduino is set to 8 secs.
Then when setting up the logging interval in 1 min (60 secs)

    const int StepTime            = 60;

The result in the serial/file debugging looks like this

    Logging to: LOGGER18.CSV
    Date/time, MPX, Solar-Panel, Batt
    1311819062,Sleep for,0.50 ***
    "2011/7/28 2:11:3",592.00,627.00,682.00
    1311819063,Sleep for,8.00 ***
    1311819071,Sleep for,8.00 ***
    1311819079,Sleep for,8.00 ***
    1311819088,Sleep for,8.00 ***
    1311819096,Sleep for,8.00 ***
    1311819105,Sleep for,8.00 ***
    1311819113,Sleep for,8.00 ***
    1311819121,Sleep for,1.00 ***
    1311819122,Sleep for,0.50 ***
    "2011/7/28 2:12:3",592.00,627.00,682.00

So in 1 minute it checks out seven times if it was time to wake up. Then when setting log time to 1 hr, the code makes the Arduino check about 450 times without any need of it :~.

I figured out the SleepTimeIndex and the indexation of the vector, but have not been able to correctly setup the watchdog in order to use other SleepTime Indexes allowing larger sleep time intervals.

///////////////
// GoToSleep //
///////////////
// set system into the sleep state 
// system wakes up when watchdog is timed out
void GoToSleep()
{
  cbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter OFF
  sleep_enable();
  sleep_mode();                        // System sleeps here
  sleep_disable();                     // System continues execution here when watchdog timed out 
  sbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter ON
}

///////////////////
// SetupWatchdog //
///////////////////
void SetupWatchdog(int SleepTimeIndex)
{
  byte bb;
  int ww;
  if (SleepTimeIndex > 9 ) SleepTimeIndex=9;
  bb=SleepTimeIndex & 7;
  if (SleepTimeIndex > 7) bb|= (1<<5);
  bb|= (1<<WDCE);
  ww=bb;
  MCUSR &= ~(1<<WDRF);
  // start timed sequence
  WDTCSR |= (1<<WDCE) | (1<<WDE);
  // set new watchdog timeout value
  WDTCSR = bb;
  WDTCSR |= _BV(WDIE);
}

/////////
// ISR //
/////////
// Watchdog Interrupt Service: executed when watchdog timed out
ISR(WDT_vect)
{
  f_wdt=1;  // set global flag
}

///////////////////////
// GetSleepTimeIndex //
///////////////////////
int GetSleepTimeIndex(uint32_t TargetTime)

if (TargetTime > 8)
  {
    SleepTimeIndex = 9;
  }
  else if (TargetTime > 4)
  {
    SleepTimeIndex = 8;
  }
  else if (TargetTime > 2)
  {
    SleepTimeIndex = 7;
  }
  else if (TargetTime > 1)
  {
    SleepTimeIndex = 6;
  } 
  else
  {
    SleepTimeIndex = TimingTolerance; 
  }
  return SleepTimeIndex; 
}
//////////////////
// GetSleepTime //
//////////////////
float GetSleepTime(int SleepTimeIndex)
{
   float SleepTimes[] = {0.016, 0.032, 0.064, 0.128, 0.250, 0.500, 1, 2, 4, 8};
  float SleepTime;
  
  SleepTime = SleepTimes[SleepTimeIndex];

  return SleepTime;
}

Any hint is more than welcomed.

AGT

Using a sleep mode is only half the battle in terms of conserving power. Check out the Atmel "Pico Power" document for more hints. I have written up my experiment with interrupts and power conserving modes, which you might be able to expand upon.

Thanks for pointing out the sleep time library, I was wondering if such a thing had already been created :slight_smile:

I suspect that the power drain is unrelated to the constant waking up — that waking up is only to be expected. The Arduino will be chewing power constantly due to the regulator having a very high "quiescent" power draw (or so I am told).

If you really want to make the Arduino sleep for longer, disable the watchdog timer and use a RTC chip with an intervalometer or alarm 8)

Here's another example of low power to see if it gives you any insight:

http://interface.khm.de/index.php/lab/experiments/sleep_watchdog_battery/

I am curious: how much power does the MPX2010DP use? According to its spec

http://www.freescale.com/files/sensors/doc/data_sheet/MPX2010.pdf

it's 6mA, but if that's continuous, then that can add up over time. If it's connected to the Arduino and sleeps with it, then of course that's much better...

Thank you for the replys and hints.

Very usefull, still understanding and assimilating the info.

I'm actually using a setup that uses a digital channel as OUTPUT (D8) to trigger a 5V relay (THD-0501L) enabling circuit feeding. The circuit includes the mentioned MPX2010DP, one 1N4007 diode, one 2N2222 transistor, one 100k resistance and an instrumental amplifier INA125P.
The whole thing uses about 70 mAh for about 55 milisecs and then turns off the battery drain from the circuit and saving as much as possible uth the code. To achieve this I had to work a little.

I modified the code external reference line:

 const boolean UseExternalARef =true;

to

 const boolean UseExternalARef =false;

and bypassed the reference voltage from INA125 (pin 4) and unplugged the Arduino's VoltageReference pin and use the pre-filtered 3.3V from the adafruit loggershield to feed the circuit through the relay. The 3.3V output is very, very stable allowing a stability and thus good performance of the whole thing.
I had to give some time to warm up the MPX (25 milisecs) and allow give the ADC some time to proper conversion of values (15 milisecs).
I further included a voltage divider to monitor the battery voltage into analog channel 1, the levelogger performs better than earlier and have been working non-stop logging data every 5 secs for three days now and the 6V 1.2 Ah battery shows no signal of drain with an almost unchanged (6.35 V) supply.

It seems that I achieved some significant battery saving. I'll include the schematics and code when the tests are done.

Thanks again
AGT

albertogt:
It seems that I achieved some significant battery saving. I'll include the schematics and code when the tests are done.

Congrats - looking forward to your power-saving code