Data Logger Shield current consumption results
Moderators: adafruit_support_bill, adafruit

Data Logger Shield current consumption results

by Lapatate on Tue Apr 10, 2012 9:24 pm

I've made some mesurments on the power consumption of the Data Logger Shield together with a Atmega328. This was relevant for a a long time logging project. The values are to be associated with the following set-up:

Basically the data logging shiel from Adafruit is directly controlled through the Atmega328 on a breadboard with an external oscillator 16Mhz.

Current when iddle: 26.4 mA

Current in Power Down mode with Watchdog Timer: 0.45 mA

I needed to reduce the power consumption as far as possible, that's why the Atmega is on a breadboard without the arduino periferals that all consume a little current even when the controller is in sleep mode. The watchdog timer is used to wake from sleep once every 59.5 seconds (looping 115 times for 0.5 sec) and the measurents are taken and written to the SD card, the RTC of the Logger shield triggers the controller back to sleep every full minute. The result is approx. 0,5 sec of processing and 59,5 sec of power down mode.

With a Lipo battery of 1730 mAh this allows for app. 90 days operation with a 1 measure every minute.

Gives lot of reasons to be zen...
Lapatate
 
Posts: 14
Joined: Thu Nov 10, 2011 5:56 pm
Location: Berlin

Re: Data Logger Shield current consumption results

by adafruit_support_bill on Wed Apr 11, 2012 5:47 am

Nice work! A lot of people ask about low-power operation and will be interested in your results.
User avatar
adafruit_support_bill
 
Posts: 31071
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logger Shield current consumption results

by Lapatate on Sun Apr 15, 2012 11:24 am

The previous values where approximativ as the current measured over a 0,5sec interval for logging, so repeating the measurements with more time for the "wake" mode and for every component seperately to see what is consuming how much.

In the earlier described configuration

During Processing, Read-out and Logging:

Data Logger Shield: app. 14.6mA
Atmega328-PU at 16Mhz with external oscillator: 12,9mA
The DHT22 Temperature and Humidity sensor: 1,5mA

Total app.: 29mA

During sleep(Power Down with WDT), no sensor read-out:

Data Logger Shield: 0,160mA
Atmega power down with WDT enabled: 0,28mA
The DHT22 Temperature and Humidity sensor (no readout): 0,012mA

Total app.: 0,45mA

All elements in the circuit are powered at 4,9V through a lipo Rider.

Enjoy your week-end!
Lapatate
 
Posts: 14
Joined: Thu Nov 10, 2011 5:56 pm
Location: Berlin

WDT timer accuracy for sleep and data logging

by Lapatate on Thu May 10, 2012 2:29 pm

After further looking into the power saving method it seems the Watch dog timer can be quite usefull when you need the AVR to sleep for longer periods and then to wake up on the choosen interval . To precisely use timing and WDT Prescaler better accuracy can be obtained considering the WDT frequency from graph 29-35 of p345 from the ATmega documentation than the frequency metionned in WDT description on page 54.

The WDT clock is really near 112.5Khz at room temperature and 5V rather than 128Khz which can make difference of a couple of ms for the typical timeouts.

If your WDT is not doing what you want this might the glitch.
Lapatate
 
Posts: 14
Joined: Thu Nov 10, 2011 5:56 pm
Location: Berlin

Re: Data Logger Shield current consumption results

by Cra451 on Tue May 15, 2012 6:36 pm

Do you have any docs/links on how the watchdog timer works?
Cra451
 
Posts: 13
Joined: Fri Nov 26, 2010 7:26 pm

Re: Data Logger Shield current consumption results

by Cra451 on Tue May 15, 2012 7:18 pm

I found a couple of links on watch dog timers. For my data logger some of the sensors are slow so the 8 second setting worked for me.

http://tushev.org/articles/electronics/ ... hdog-timer

http://www.nongnu.org/avr-libc/user-man ... chdog.html
Cra451
 
Posts: 13
Joined: Fri Nov 26, 2010 7:26 pm

Re: Data Logger Shield current consumption results

by Lapatate on Wed Jul 04, 2012 2:44 am

Hello,
A very simple and examplary application using WDT and SLEEP is probably this one:

http://interface.khm.de/index.php/lab/e ... g_battery/

It'll probably turn up in various threads about this topic. For the rest I used the ATmega documentation for more in deept timing settings and sleep modes.

Regards,
Lapatate
Lapatate
 
Posts: 14
Joined: Thu Nov 10, 2011 5:56 pm
Location: Berlin

Re: Data Logger Shield current consumption results

by bethesdakid on Wed Aug 08, 2012 4:08 pm

Thanks, this is an extremely significant advancement.
Using 4 rechargeable AA batteries with a Pro and Logger the power problem is solved. The system will run for over 2 months.

See my update TURN LOGGER ON/OFF power down current is 0.623 ma. The 4 ea AA rechargeables have a 2400 maH capability. A mod to reduce the current was to delete both the Pro and Logger power LEDs off by lifting an LED resistor pad. The sleep current now falls to 0.6ma.
Last edited by bethesdakid on Tue Jan 14, 2014 11:43 am, edited 3 times in total.
bethesdakid
 
Posts: 58
Joined: Sat Apr 28, 2012 6:23 pm
Location: Washington dc

Re: Data Logger Shield current consumption results

by adafruit_support_bill on Wed Aug 08, 2012 4:51 pm

Writing to a USB flash drive from the Arduino is not possible (at least not without getting pretty deep into USB protocols).

But most computers these days have SD card slots because that is a common format for digital cameras. Check the specs for your Mac, if it is of recent vintage it likely has one.
User avatar
adafruit_support_bill
 
Posts: 31071
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logger Shield current consumption results

by bethesdakid on Wed Aug 28, 2013 9:49 pm

See results in turn on/off
Last edited by bethesdakid on Wed Dec 25, 2013 5:22 pm, edited 1 time in total.
bethesdakid
 
Posts: 58
Joined: Sat Apr 28, 2012 6:23 pm
Location: Washington dc

Re: Data Logger Shield current consumption results

by bethesdakid on Thu Sep 19, 2013 10:33 am

Results. A for loop of 1511 cycles will run at 0.623 mills for 4 hours. The change in the 4 hour increment is about 2 second per day. The on current is roughly 23 mills for less than a second. the batteries should last more than 2-3 months.
the unit was installed in the box on 1/8/2014
Last edited by bethesdakid on Wed Jan 08, 2014 10:03 pm, edited 1 time in total.
bethesdakid
 
Posts: 58
Joined: Sat Apr 28, 2012 6:23 pm
Location: Washington dc

Re: Data Logger Shield current consumption results

by adafruit_support_rick on Thu Sep 19, 2013 10:36 am

Who are you asking for code? What code are you looking for?

adafruit_support_rick
 
Posts: 13111
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Data Logger Shield current consumption results

by bethesdakid on Sat Oct 12, 2013 2:05 pm

Have solved the programing and power problems
thanks to this topic and the suggestions that it offers.

You have done a good service to those struggling like I did to get a device that logged for months in the wild away from wireless.

help
Last edited by bethesdakid on Tue Jan 14, 2014 11:46 am, edited 2 times in total.
bethesdakid
 
Posts: 58
Joined: Sat Apr 28, 2012 6:23 pm
Location: Washington dc

Re: Data Logger Shield current consumption results

by bethesdakid on Wed Oct 16, 2013 9:49 pm

have you looked into using an Arduino Pro which can connect to the logger pin-for-pin like the Rev3 except it has eliminated many of the Rev3 components and should save power.

After collecting data on the Pro and doing a proof of concept, my system is working successfully.
It logs several environment parameters with a 4 AA power pack that runs for over 2 months.
Last edited by bethesdakid on Tue Jan 14, 2014 11:34 am, edited 1 time in total.
bethesdakid
 
Posts: 58
Joined: Sat Apr 28, 2012 6:23 pm
Location: Washington dc

Re: Data Logger Shield current consumption results

by Lapatate on Thu Oct 24, 2013 7:25 am

This is the code with some power saving features in it. I am again working on this in the last days.
It uses a ATM328 bare-bones connected to the adafruit logger shield and is powered by 4 NiMH batteries and a small solar cell.

Power consumption during:
wake: 18 mA (1sec every 4 Seconds)
power_down: 0.56mA (4 seconds)
Write to SD card: app. 200mA (25ms once every 5 minutes)

This averages to 5mA continuous current consumption of the system at 4.8V to 5V.

Should give me an autonomie of 7.8 days on 900mAh without accounting recharging form the solar cell. I don't know if I can reach the break even point at this stage with my solar cell 5,5V 180mA in the winter. I am trying this out currently. Whish me luck!!


Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>                           //Ic2 library
#include <SdFat.h>                          //SD card library 
#include "RTClib.h"                         //real time clock library
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>

#define MEASURE_INTERVAL 1000
#define ECHO_TO_SERIAL  1                   //echoes data to serial port
#define redLEDpin 3

RTC_DS1307 RTC;                             //define the Real Time Clock object

SdFat sd;                     

const int chipSelect = 10;                  //for the data logging shield we use pin 10 for the SD cs line
const int arraylength = 60;                 //values to store in the array 60 = every 5 min
int countlogs = 0;                       
int sensorCount = 0;
long lastMillisMeasure = 0;
float wSpeed = 0;
int lastmonth;
int sensorValues[arraylength][3];           

SdFile logfile; 

ISR(WDT_vect){
}

void error (char *str){
  Serial.print("error: ");
  Serial.println(str);
  PORTD |= B1000; // digitalWrite(redLEDpin, HIGH);           
  while(1);
  //delay(5000);
}

void dateTime(uint16_t* date, uint16_t* time) {
  DateTime now = RTC.now();
  // return date using FAT_DATE macro to format fields
  *date = FAT_DATE(now.year(), now.month(), now.day());
  // return time using FAT_TIME macro to format fields
  *time = FAT_TIME(now.hour(), now.minute(), now.second());
}

void openfile(){
  DateTime now = RTC.now();
  if (lastmonth != now.month()){        //Creating a new file every month
    lastmonth = now.month();
    newfile();
  }
  else{
    SdFile::dateTimeCallback(dateTime);   // callback for file timestamps
    char filename[] = "LOGGER00.csv";
    if (!logfile.open(filename, O_RDWR | O_CREAT | O_EXCL |O_AT_END)) {      //if base file exists count cycle to last file number
      //sd.errorHalt("opening file for write failed");
      Serial.print("OF");
      char filename[] = "LOGGER99.csv";
      for (uint8_t i = 99; i >= 0; i--) {
        filename[6] = i/10 +'0';
        filename[7] = i%10 +'0';
        logfile.open(filename, O_RDWR | O_AT_END);       //try to open file
        if (logfile.isOpen()){             //if file can be openend the use     
         Serial.print("Logging to: ");
         Serial.println(filename);
         break;                                         //leave the loop
        } 
      }
    }
    else {       // if no base file exists create one
      Serial.print("BF");
      char filename[] = "LOGGER00.csv";
      logfile.open(filename, O_RDWR | O_CREAT | O_AT_END);
      Serial.print("Logging to: ");
      Serial.println(filename);
      Serial.println("Time, WindSpeed, WindDirection, Batt Voltage, Cell Voltage");
      logfile.println("Time, WindSpeed, WindDirection, Batt Voltage, Cell Voltage");
    }
  }
}

void newfile(){
  Serial.print("NF");
  char filename[] = "LOGGER00.csv";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 +'0';
    filename[7] = i%10 +'0';
    logfile.open(filename, O_RDWR | O_CREAT | O_EXCL | O_AT_END); // only open a file if it doesn't exist
    if (logfile.isOpen()) {
    Serial.println(", WindSpeed, WindDirection, Batt Voltage, Cell Voltage");
    logfile.println(", WindSpeed, WindDirection, Batt Voltage, Cell Voltage");
    break;                                            //leave the loop
    }
  }
}

void count(){
  ++sensorCount;
}

void setup(){
  Serial.begin(115200);
  Wire.begin();
  RTC.begin();
    if (! RTC.isrunning()) {
      Serial.println("RTC is NOT running!");
      RTC.adjust(DateTime(__DATE__, __TIME__));    //sets the RTC to the date & time this sketch was compiled
    }
  DateTime now = RTC.now();
  lastmonth = now.month();

  DDRD = DDRD | B00000000; // sets PORTD register pin 3 to 7 to input leaving pin 0 & 1 which are RX & TX and pin 2 for the sensor
  PORTD = B00000000; // sets digital pins 7 to 0 LOW
  DDRB = B000000; // sets PORTB register pin 8 to 13 to input
  PORTB = B000000; // sets digital pins 8 to 13 LOW
  DDRC = B000000; //  sets PORTC register pin 2 to 5 to input
  PORTC = B000000; // sets analog pins 0 to 5 LOW

  SMCR = B00000100; // Sleep Mode Control Resgister sets sleep mode type to POWER_DOWN
  PRR = B01001000; // Power Reduction Register shuts down: TWI, "Timer2", Timer0, , "Timer1", SPI, USART0, ADC

  pinMode(13, OUTPUT);
  pinMode(redLEDpin, OUTPUT);
  pinMode(10, OUTPUT);
  attachInterrupt(0, count, CHANGE);

  Serial.println("Initialising WDT...");
  MCUSR &= ~(1<<WDRF);
  WDTCSR |= (1<<WDCE) | (1<<WDE);
  WDTCSR = 1<<WDP1; // app 66,4 ms seconds cycle at 5V 20C
  WDTCSR |= _BV(WDIE); // Enable the watchdog timer Interrupt;
  Serial.println("WDT Initialisation complete!");

}

void loop(){
  if (millis()-lastMillisMeasure >= MEASURE_INTERVAL){  // If a time of "interval" is elapsed the wind speed calculation is performed
    lastMillisMeasure = millis();                         // sets the lastMillis to the current time
    wSpeed = (float(sensorCount) / 4.0) * 1.118;          // Assuming 4 sensor transitions per revolutiona and 1.118 m/s wind per rev/sec                                                   
    power_adc_enable();
    bitClear(ADCSRA,ADPS0) ;
    bitClear(ADCSRA,ADPS1) ;
    bitSet(ADCSRA,ADPS2) ;
    int battVoltage = analogRead(A0);  // Disgard first conversion
    int cellVoltage = analogRead(A1);  // Disgard first conversion
    battVoltage = analogRead(A0);  // Reads the voltage of the solar Cell on A1 pin /1023*5.0       
    cellVoltage = analogRead(A1);  // Reads the voltage of the solar Cell on A1 pin /1023*5.0       
    power_adc_disable();
    sensorValues[countlogs][0] = millis();
    sensorValues[countlogs][1] = cellVoltage;
    sensorValues[countlogs][2] = battVoltage;
    Serial.print(countlogs);
    Serial.print(" ");
    Serial.print(sensorValues[countlogs][1]);
    Serial.print(" ");
    Serial.println(sensorValues[countlogs][2]);
    countlogs++;
    delay(4);   
    PORTD |= B1000;  // digitalWrite(redLEDpin, HIGH);
    delay(1);
    digitalWrite(redLEDpin, LOW);
    sleepNow();
  }


  if (countlogs >= arraylength) {
    power_spi_enable();
    power_twi_enable();
    Wire.begin();
    RTC.begin();
    if (! RTC.isrunning()) {
      Serial.println("RTC is NOT running!");
      RTC.adjust(DateTime(__DATE__, __TIME__));    //sets the RTC to the date & time this sketch was compiled
    }

    Serial.print("Initializing SD Card...");
    if (!sd.begin(chipSelect,SPI_FULL_SPEED))  {                  //See if card is present and can be initialized
      error("Card failed, or not present");
      Serial.print("Card failed, or not present");   
      return;
    }
    Serial.println("Card initialized");

    openfile();
   
    DateTime now = RTC.now();
    Serial.print(now.year(), DEC);
    Serial.print("/");
    Serial.print(now.month(), DEC);
    Serial.print("/");
    Serial.print(now.day(), DEC);
    Serial.print(", ");
    Serial.print(now.hour(), DEC);
    Serial.print(":");
    Serial.print(now.minute(), DEC);
    Serial.print(":");
    Serial.println(now.second(), DEC);
    logfile.print(now.year(), DEC);
    logfile.print("/");
    logfile.print(now.month(), DEC);
    logfile.print("/");
    logfile.print(now.day(), DEC);
    logfile.print(" ");
    logfile.print(now.hour(), DEC);
    logfile.print(":");
    logfile.print(now.minute(), DEC);
    logfile.print(":");
    logfile.println(now.second(), DEC);

    for(int i = 0; i<arraylength ; i++) {
      for (int j = 0; j<3 ; j++) {
        Serial.print(sensorValues[i][j]);
        Serial.print(", ");
        logfile.print(sensorValues[i][j]);
        logfile.print(", ");
      }
      Serial.println();
      logfile.println();
    }
    delay(10);
    logfile.close();
    countlogs=0;
  }   
}


void sleepNow(){
  detachInterrupt(0);
  //  Serial.print("going to sleep");
  for (int i=0; i < 60 ; ++i) {      //60 going to sleep for app. 4 seconds
    MCUCR = _BV (BODS) | _BV (BODSE);
    MCUCR = _BV (BODS);
    sleep_mode();
  }
  power_adc_disable();
  power_spi_disable();
  power_timer1_disable(),
  power_timer2_disable(),
  power_twi_disable();
  attachInterrupt(0, count, CHANGE);
  lastMillisMeasure = millis();    // sets the lastMillis to the current time
  sensorCount=0;
}


To really achieve more autonomy a low power 3.3V RTC with watchdog function should allow me to run everything at 3.3V, this should reduce the consumption about half, I am hoping for it.

So long
Last edited by Lapatate on Tue Oct 29, 2013 1:26 pm, edited 1 time in total.
Lapatate
 
Posts: 14
Joined: Thu Nov 10, 2011 5:56 pm
Location: Berlin