Data Logger Shield current consumption results

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Lapatate
 
Posts: 14
Joined: Thu Nov 10, 2011 5:56 pm

Re: Data Logger Shield current consumption results

Post by Lapatate »

Hello,

Is there a code possible to have the ATM328 in sleep mode idle between interrupts but with the condition to wake after preset interval.

Example:

Got to sleep_mode_idle
Interrupt > store millis() > go back to sleep_mode_idle
interrupt > Store millis() > go back to sleep_mode_idle
Wake up if sleep_mode_idle is longer than 1000ms

Within a maximum amount of 1000ms I need to take an interval measurment with the microcontroller sleeping in between.

Maybe someone has a bright idea how to code that.

Regards

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logger Shield current consumption results

Post by adafruit_support_bill »

There are a few sleep libraries out there. Here's the one from Arduino Playground: http://playground.arduino.cc/Learning/arduinoSleepCode

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Data Logger Shield current consumption results

Post by adafruit_support_rick »

Lapatate wrote:Wake up if sleep_mode_idle is longer than 1000ms
The CPU can't wake itself up, but you can get a Chronodot, which can be configured to produce a 1Hz square-wave output. Connect that to an external interrupt line, and it will wake the CPU every 1000ms.

EDIT: I take that back. In "Power Save" mode, Timer 2 continues to run, and it can be used to wake the CPU. From section 10.6 of the ATmega328 data sheet:
10.6 Power-save Mode
When the SM2...0 bits are written to 011, the SLEEP instruction makes the MCU enter Power-save mode. This mode is identical to Power-down, with one exception:
If Timer/Counter2 is enabled, it will keep running during sleep. The device can wake up from either Timer Overflow or Output Compare event from Timer/Counter2 if the corresponding Timer/Counter2 interrupt enable bits are set in TIMSK2, and the Global Interrupt Enable bit in SREG is set.

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

Re: Data Logger Shield current consumption results

Post by Lapatate »

Thank you,

I managed to get the the MCU to exit sleep idle after 1000ms with a timer2, that's 1 step of the problem solved.

The second part:

Now in between this I need to wake up with an interrupt, store the time, and get back to sleep idle. This should be done twice but after the first interrupt the mcu doesn't get back into sleep mode idle again (althought told so) an triggers a second interrupt right away.

It might be an issue of debouncing the interrupt, or the because the first sleep mode is issued with a wake up from timer 2 interrupt and it interferrs with the second call for sleep mode idle after the signal interrupt.

Hmm..

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Data Logger Shield current consumption results

Post by adafruit_support_rick »

Lapatate wrote:Now in between this I need to wake up with an interrupt, store the time, and get back to sleep idle. This should be done twice but after the first interrupt the mcu doesn't get back into sleep mode idle again (althought told so) an triggers a second interrupt right away.
You probably have to clear the interrupt flag in the control register before you go back to sleep.

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

Re: Data Logger Shield current consumption results

Post by Lapatate »

Thank you!

bethesdakid
 
Posts: 61
Joined: Sat Apr 28, 2012 6:23 pm

Re: Data Logger Shield current consumption results

Post by bethesdakid »

A 5V Arduino Pro takes 0.623 milliamps at 4.6 V during the 8 second watch dog period. With it set inside a 7 time FOR loop , a blink to the LED on the board repeats about every minute drawing about 12-13 milliamps. I plan to use it with a logger shield that fits it like a Uno.

This system is going to be placed in the woods and needs to be compact although it will be in a warm environment 40-80 F). Powered by 4ea AA rechargeables it should last at least 5 months when the for loop is set for every two hours...

As you have found, the Uno is not suitable for projects like this one. (just look at my past notes on powering it for long battery life). You are using the controller chip by itself, however the Pro is USB FTDI connected with programing and resetting like the UNO.With the logger on the current goes to over 40 mills, so the for loop will be adjusted to minimize the current drain... the logger needs to be strobed only 3-4 times a day.

The best thing is it is compact and low power...

Glad to share getting started with the Pro...

stay loose as buddha

bethesdakid
 
Posts: 61
Joined: Sat Apr 28, 2012 6:23 pm

Re: Data Logger Shield current consumption results

Post by bethesdakid »

The Arduino Pro 5V 328 in sleep mode uses 0.623 ma. However, when the logger shield is connected, The SD test reads "uninitialized".
The problem was solved. it was a bad contact on the pro which when repaired put the rail on the logger and the system functions nominally...
And here is a way to extend a low power WDT for any period of time using a "for loop"

void loop()
{
for(int i=0; i<3; i++){ // i<3 gives a about a 16-18 second power down to 0.623mA,
// change to i<5 produces ~40 second power down...etc

// Enter power down state for 8 s with ADC and BOD module disabled
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
// 623microamps sleep 8sc plus 1 sec off blink
// 12-15 milliamps blink on
// Do something here
// Example: Read sensor, data logging, data transmission.
// Pin 13 has an LED connected on most Arduino boards.
// the loop routine runs over and over again forever:
}
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000);
Last edited by bethesdakid on Tue Dec 10, 2013 12:38 pm, edited 1 time in total.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Data Logger Shield current consumption results

Post by adafruit_support_rick »

The logger shield runs on 5V. It has an onboard regulator to generate 3.3V for the SD card.

bethesdakid
 
Posts: 61
Joined: Sat Apr 28, 2012 6:23 pm

Re: Data Logger Shield current consumption results

Post by bethesdakid »

just thought you would like a tip about a low power arduino. The arduino Pro has the same pinouts as the Uno. With the WDT on, the power is: 0.623ma at 5V. [There is a 3V Pro version too which probably runs at less than 0.4 ma.] When the logger is added the current is over 2 ma. To reduce the logger current the power LED on the board is shut down by bending up the LED resistor (which voids the warrant). Now the total current is 1.04 ma. That is doable if operating from 4 ea AA li rechargeables. My system turns on every 4 hours to collect sensor data. I published a "FOR" program that can cycle the WDT for any period of time (a <3 cycle is about 20 sec, so a <7 is ~1 min, an hour ~<361 and 4 hour ~<1441) The batteries should last about 60-90 days.

To those using a battery system., I will archive battery system data. Please send this data:
1. controller and change to it
2. logger and change to it
3. Battery pack
4. WDT time between data collection periods
5, sensors

It will be good to let others know what can be accomplished with a self-contained system

Thanks

Ken Brown AKA Bethesdakid

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

Re: Data Logger Shield current consumption results

Post by Lapatate »

Some Thoughts,

Advantages can be expected when replacing the DS1307 against the DS1338 to extend the operation range towards lower voltages.

Currently the DS1307 timestamps for logging stop at 3.7V, whereas the SD card works down to 2.7V.

Eventually a furhter version of the logger shield could be with a migration to the MCP7940N (also low cost) for wider operation voltages.

http://ww1.microchip.com/downloads/en/D ... 02337B.pdf

Is there an other versions in planning?

Regards

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logger Shield current consumption results

Post by adafruit_support_bill »

Thanks for the suggestion. The board was updated fairly recently and remains one of our best sellers. I will forward your request to the design team.

bethesdakid
 
Posts: 61
Joined: Sat Apr 28, 2012 6:23 pm

Re: Data Logger Shield current consumption results

Post by bethesdakid »

the third try...5/19
In the URL: learn.adafruit.com/adafruit-data-logger-shield/using-the-real-time-clock-3
Listing the Code Walkthrough. I copied each section and put it together to program the logger.

Below is the Complete code. When compiled it returns an error message as follows:
Arduino: 1.6.8 (Mac OS X), Board: "Arduino/Genuino Uno"

/

Code: Select all

Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware "/Applications/Arduino.app/Contents/Java/hardware" -tools "/Applications/Arduino.app/Contents/Java/tools-builder" -tools "/Applications/Arduino.app/Contents/Java/hardware/tools/avr" -built-in-libraries "/Applications/Arduino.app/Contents/Java/libraries" -libraries "/Users/bethesdakid/Documents/Arduino/libraries" -fqbn=arduino:avr:uno -ide-version=10608 -build-path "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp" -warnings=default -prefs=build.warn_data_percentage=75 -verbose "/Users/bethesdakid/Documents/arduino/LOGGING_sketch_example/LOGGING_sketch_example.ino"
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware "/Applications/Arduino.app/Contents/Java/hardware" -tools "/Applications/Arduino.app/Contents/Java/tools-builder" -tools "/Applications/Arduino.app/Contents/Java/hardware/tools/avr" -built-in-libraries "/Applications/Arduino.app/Contents/Java/libraries" -libraries "/Users/bethesdakid/Documents/Arduino/libraries" -fqbn=arduino:avr:uno -ide-version=10608 -build-path "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp" -warnings=default -prefs=build.warn_data_percentage=75 -verbose "/Users/bethesdakid/Documents/arduino/LOGGING_sketch_example/LOGGING_sketch_example.ino"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp/sketch/LOGGING_sketch_example.ino.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp/sketch/LOGGING_sketch_example.ino.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp/sketch/LOGGING_sketch_example.ino.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp/sketch/LOGGING_sketch_example.ino.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp/sketch/LOGGING_sketch_example.ino.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master/RTClib.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src/SPI.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "/Applications/Arduino.app/Contents/Java/libraries/SD/src/File.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "/Applications/Arduino.app/Contents/Java/libraries/SD/src/SD.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "/Applications/Arduino.app/Contents/Java/libraries/SD/src/utility/Sd2Card.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "/Applications/Arduino.app/Contents/Java/libraries/SD/src/utility/SdFile.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "/Applications/Arduino.app/Contents/Java/libraries/SD/src/utility/SdVolume.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src/Wire.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src/utility/twi.c" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp/sketch/LOGGING_sketch_example.ino.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp/sketch/LOGGING_sketch_example.ino.cpp" -o "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp/preproc/ctags_target_for_gcc_minus_e.cpp"
"/Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino10/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp/preproc/ctags_target_for_gcc_minus_e.cpp"
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os  -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src" "-I/Applications/Arduino.app/Contents/Java/libraries/SD/src" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src" "-I/Users/bethesdakid/Documents/Arduino/libraries/RTClib-master" "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp/sketch/LOGGING_sketch_example.ino.cpp" -o "/var/folders/fn/y070470n6bn3jys6h4jh0b4m0000gn/T/buildad5718dd6c6304226551c3f4fc1e07e7.tmp/sketch/LOGGING_sketch_example.ino.cpp.o"
/Users/bethesdakid/Documents/arduino/LOGGING_sketch_example/LOGGING_sketch_example.ino: In function 'void setup()':
/Users/bethesdakid/Documents/arduino/LOGGING_sketch_example/LOGGING_sketch_example.ino:94:32: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     error("couldnt create file");
                                ^
LOGGING_sketch_example:120: error: 'class SDLib::File' has no member named 'writeError'
 if (logfile.writeError || !logfile.sync()) {
             ^
LOGGING_sketch_example:120: error: 'class SDLib::File' has no member named 'sync'
 if (logfile.writeError || !logfile.sync()) {
                                    ^
/Users/bethesdakid/Documents/arduino/LOGGING_sketch_example/LOGGING_sketch_example.ino:121:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       error("write header");
                           ^
LOGGING_sketch_example:125: error: 'endif' was not declared in this scope
   endif
   ^
LOGGING_sketch_example:133: error: expected ';' before 'void'
 void loop(void)
 ^
LOGGING_sketch_example:151: error: 'now' was not declared in this scope
   now = RTC.now();
   ^
Multiple libraries were found for "SD.h"
 Used: /Applications/Arduino.app/Contents/Java/libraries/SD
 Not used: /Users/bethesdakid/Documents/Arduino/libraries/SD-master
Using library RTClib-master at version 1.2.0 in folder: /Users/bethesdakid/Documents/Arduino/libraries/RTClib-master 
Using library SPI at version 1.0 in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI 
Using library SD at version 1.0.8 in folder: /Applications/Arduino.app/Contents/Java/libraries/SD 
Using library Wire at version 1.0 in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire 
exit status 1
'class SDLib::File' has no member named 'writeError'[/i]

Code: Select all

//__________________INCLDES AND DEFINES___________

 #include <RTClib.h>  // for chatting with the real time clock 
#include <SPI.h>
#include <SD.h>  //SD library to talk to the card
#include <Wire.h>     //Wire library seeks the i2c modules 
                        //and chips
                     
// A simple data logger for the Arduino analog pins
#define LOG_INTERVAL  1000 // mills between entries
#define ECHO_TO_SERIAL   1 // echo data to serial port
#define WAIT_TO_START    0 // Wait for serial input in setup()
#define DateTime

// the digital pins that connect to the LEDs
#define redLEDpin 3
#define greenLEDpin 4

// The analog pins that connect to the sensors
#define photocellPin 0           // analog 0
#define tempPin 1                // analog 1

//_____________END ARDUINO digital & analog pins________

//__________________OBJECTS AND ERROR()________

RTC_DS1307 RTC; // define the Real Time Clock object

// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 10;

// the logging file
 
File logfile;

void error(char *str)
{
  Serial.print("error: ");
  Serial.println(str);
 // red LED indicates error
  digitalWrite(redLEDpin, HIGH);
  
  while(1);
}
 //_______________END OBJECTS AND ERROR()________

  //______________SETUP____________________
  
void setup(void)
{
  Serial.begin(9600);
  Serial.println();
  
#if WAIT_TO_START
  Serial.println("Type any character to start");
  while (!Serial.available());
#endif //WAIT_TO_START

/*now we are onto the code. We begin by initializing 
 *the Serial port at 9600 baud. If we set WAIT_TO_START 
  to anything but 0, the Arduino will wait until the 
  user types something in. Otherwise it goes ahead to 
  the next part
  */
  //________initialize the SD card___________ 
   // initialize the SD card
  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);
  
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
  
  // create a new file
  char filename[] = "LOGGER00.CSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      logfile = SD.open(filename, FILE_WRITE); 
      break;  // leave the loop!
    }
  }
  
  if (! logfile) {
    error("couldnt create file");
  }
  
  Serial.print("Logging to: ");
  Serial.println(filename);
//___________END INITIALIZE SD card_______________

 /*Now the code starts to talk to the SD card, it tries 
  * to initialize the card and find a FAT16/FAT32 
  * partition. */
 //___________BEGIN TALK TO SD card_______________

   Wire.begin();  
  if (!RTC.begin()) {
    logfile.println("RTC failed");
#if ECHO_TO_SERIAL
    Serial.println("RTC failed");
#endif  //ECHO_TO_SERIAL
  }
  
  logfile.println("millis,time,light,temp");    
#if ECHO_TO_SERIAL
  Serial.println("millis,time,light,temp");
#if ECHO_TO_SERIAL// attempt to write out the header to  file

 //___________PROGRAM ERRORS BEGIN HERE______________
if (logfile.writeError || !logfile.sync()) {
      error("write header");
 }
   pinMode(redLEDpin, OUTPUT);
  pinMode(greenLEDpin, OUTPUT);
  endif
#endif 
#endif
   // If you want to set the aref to something other than 5v
  //analogReference(EXTERNAL);
//___________END TALK TO SD card_______________
//_________________MAIN LOOP____________________
//___________________TIMESTAMPING_______________
void loop(void)
  //  DateTime nowTHIS SUCCEEDS function-definition not allowed

  // delay for the amount of time we want between readings
  delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));
  
  digitalWrite(greenLEDpin, HIGH);

  // log milliseconds since starting
  uint32_t m = millis();
  logfile.print(m);           // milliseconds since start
  logfile.print(", ");    
#if ECHO_TO_SERIAL
  Serial.print(m);         // milliseconds since start
  Serial.print(", ");  
#endif

  // fetch the time
  now = RTC.now();
  // log time
  logfile.print(now.get()); // seconds since 2000
  logfile.print(", ");
  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.print(now.second(), DEC);

#if ECHO_TO_SERIAL
  Serial.print(now.get()); // seconds since 2000
  Serial.print(", ");
  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.print(now.second(), DEC);
#endif //ECHO_TO_SERIAL

 /*The first important thing is the delay() call, this 
  * is what makes the Arduino wait around until its time to 
   *take another reading. If you recall we #defined the delay 
   between readings to be 1000 millseconds (1 second). By 
   having more delay between readings we can use less power 
   and not fill the card as fast. Its basically a tradeoff 
   how often you want to read data but for basic long term
logging, taking data every second or so will result in plenty 
of data!
Then we turn the green LED on, this is useful to tell us 
that yes we're reading/writing data now.
Next we call millis() to get the 'time since arduino turned o
on' and log that to the card. It can be handy to have - 
especially if you end up not using the RTC.
Then the familiar RTC.now() call to get a snapshot of 
the time. Once we have that, we write a timestamp (seconods 
since 2000) as well as the date in YY/MM/DD HH:MM:SS time 
format which can easily be recognized by a spreadsheet. 
We have both because the nice thing about a timestamp 
is that its going to montonically increase and the nice t
hing about printed out date is its human readable
*/
___________________END TIMESTAMPING_______________ 
_________________LOG SENSOR DATA____________________
  int photocellReading = analogRead(photocellPin);  
  delay(10);
  int tempReading = analogRead(tempPin);    
  
  // converting that reading to voltage, for 3.3v arduino use 3.3
  float voltage = tempReading * 5.0 / 1024;  
  float temperatureC = (voltage - 0.5) * 100 ;
  float temperatureF = (temperatureC * 9 / 5) + 32;
  
  logfile.print(", ");    
  logfile.print(photocellReading);
  logfile.print(", ");    
  logfile.println(temperatureF);
#if ECHO_TO_SERIAL
  Serial.print(", ");   
  Serial.print(photocellReading);
  Serial.print(", ");    
  Serial.println(temperatureF);
#endif //ECHO_TO_SERIAL

  digitalWrite(greenLEDpin, LOW);
} 

  /*This code is pretty straight forward, the processing 
   code is snagged from our earlier tutorial. Then we just 
   print() it to the card with a comma seperating the two
  We finish up by turning the green LED off
 */
___________________END SENSOR DATA LOGGING_______________
Last edited by adafruit_support_rick on Thu May 19, 2016 3:53 pm, edited 9 times in total.
Reason: please use code tags (</> button)when posting code

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logger Shield current consumption results

Post by adafruit_support_bill »

Can you be more specific? Is this a compile-time problem, or a run-time problem.
digitalWrite is not a recognized construct
digitalWrite has been part of the standard Arduino API since the beginning, and probably will be forever. You either have a corrupted version of the code or the IDE.

Please post the exact code you are using and the exact text of the error messages you are seeing.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Data Logger Shield current consumption results

Post by adafruit_support_rick »

You have a couple of warnings, which you can ignore, and some syntax errors.

You have a stray "endif" just before loop(). That's causing some other errors.

Code: Select all

   pinMode(redLEDpin, OUTPUT);
  pinMode(greenLEDpin, OUTPUT);
  endif
#endif 
#endif
The File object doesn't have a property 'writeError', and doesn't have a method 'sync'. I don't know where you found this code.

You haven't declared 'now' as a variable.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”