RTC challenge: new beginner

Hello everyone,

A months ago, I thought to learn programming for arduino and arduino application through a project. So looking through projects I saw online, i thought to read data off the anemometer sensor (similar to the project in http://www.hackerscapes.com/2014/11/anemometer/) which made use of the adafruit anemometer, arduino uno. However, by improving same project, I integrated the RTC 1307 and ethernet shield with SD card to read/write date, time and wind speed onto the SD card at 10 second interval with header on csv. This was successful using separate code from datalogging library, rtc library and anemometer code from http://www.hackerscapes.com/2014/11/anemometer/. However, I noticed the following;

Challenge:
1-If the entire Arduino module with rtc and ethernet shield is powered off for a while (with cmos present), it retains the last date and time when powered back on and even when I uncomment the script to adjust the time to now, it still remains same except i pull out the cmos and run the code. Any reason for that?

2-Is it possible that the rtc with cmos present keeps reading date/time even when power on the module is off such that when power is restored, date/time continues…Any suggestions

2-Based on the aforementioned, I am looking to see if the code will fully achieve the function to read/write date, time and wind speed effectively at ten minutes interval-delay(600000)

Thanks…

windspeed_datalogging.ino (5.39 KB)

I don't know what the pictures are trying to tell me, but your way of logging data is strange, to say the least.

Get the date/time. Get the data to log. Wait 10 seconds. Write the date/time and other data to the file. Repeat.

Most people would do the delay() at the start of the cycle, or at the end of the cycle, not in the middle of the cycle.

The blink without delay technique would allow you to collect data continuously, and then record average data for the 10 second period, instead of the instantaneous spike.

How do you remove the CMOS from the RTC? Removing the battery makes sense (sort of).

ASPABU:
1-If the entire Arduino module with rtc and ethernet shield is powered off for a while (with cmos present), it retains the last date and time when powered back on and even when I uncomment the script to adjust the time to now, it still remains same except i pull out the cmos and run the code. Any reason for that?

This has lost something in the translation. I think that when you say 'cmos' you mean the backup battery.

The job of the RTC is to keep track of time even when no external power is provided. That is what the battery is for. The battery can keep the clock running for hours (if it is rechargeable) or years (if it is a non-rechargeable lithium cell).

What do you WANT the clock to do when you lose power?

ASPABU:
2-Is it possible that the rtc with cmos present keeps reading date/time even when power on the module is off such that when power is restored, date/time continues...Any suggestions

The job of the RTC is to keep track of time even when no external power is provided. That is what the battery is for.

Do you want it to do something different? If you want it to do something different, what is it you want it to do?

ASPABU:
2-Based on the aforementioned, I am looking to see if the code will fully achieve the function to read/write date, time and wind speed effectively at ten minutes interval-delay(600000)

It looks like it works well at 10-second intervals. It should work as well at 10-minute intervals.

I think that when you say 'cmos' you mean the backup battery.

That all I can think of that fits the posting.

shield is powered off for a while (with cmos present), it retains the last date and time when powered back on

If the chip is not running under battery power. There's some trouble shooting you can do.

Verify the battery voltage. Insure that is installed with the correct polarity--I'm not certain about your specific module/shield, but usually that is with the + facing outward.

If the battery is good and correctly installed, there could be a circuit defect on the module which you can test for. You will need to confirm that approximately 3 v is getting to the Vbat lead of the chip. You will need to find a DS1307 data sheet and verify which chip pin is Vbat.

If the voltage is present but the rtc is not running, then you may have a defective chip or oscillator on the module. See this thread for a case of a counterfeit ds1307 chip which would not run under battery power http://forum.arduino.cc/index.php?topic=303406.0

Thanks everyone....@PaulS, pictures were results logged to the SD card. However, as my new to arduino, I will adjust the code based on your suggestions..

@johnwasser, yes my bad..cmos means backup battery. I understand that the job of the rtc is to keep track of time even when no external power is provided but mine typical has a lag in time when I power the module back on.

@cattledog, I will follow comments on http://forum.arduino.cc/index.php?topic=303406.0.