No RTC Luck on Datalogger shield

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

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
keithwins
 
Posts: 10
Joined: Sat Jun 12, 2010 2:55 pm

No RTC Luck on Datalogger shield

Post by keithwins »

I've confirmed the battery is live and the connections to the board are good. I've reloaded the script repeatedly, and double-checked that I'm running the RTC.adjust segment: I've even taken it out of Setup and put it in Loop. I've swapped in a different DS1307 chip. I've removed/replaced the battery. Sadly my DMM doesn't measure frequency, though I might be able to find one that does.

In every case I just get the default 2000/0/0. Oh, and !RTC.isrunning() always returns true, so at least everything is consistent. I'm using the default code included in RTClib/examples/ds1307.

The code segment that should be doing the heavy lifting is

Code: Select all

  if (RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
I'm sort of at my wits end. I've got another Datalogger I haven't put together yet, I'll do that soon and see if it's a build problem. Other suggestions are welcome. I think I've read everything here on it and I don't see anything I haven't tried.

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

Re: No RTC Luck on Datalogger shield

Post by adafruit_support_bill »

Did you remember the blob of solder under the battery holder? It is needed for good contact.
Post photos of the front & back. We'll have a look for any assembly issues.

Algolosaur
 
Posts: 67
Joined: Sun Apr 05, 2009 11:29 am

Re: No RTC Luck on Datalogger shield

Post by Algolosaur »

Um, I'm a bit confused here.

Code: Select all

  if (RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
You're testing if the RTC is running, but then you print it is not if it is. If the clock is not running, you never set it, which if I recall correctly, actually starts the clock.

Algolosaur

keithwins
 
Posts: 10
Joined: Sat Jun 12, 2010 2:55 pm

Re: No RTC Luck on Datalogger shield

Post by keithwins »

First: I checked directly, on the board, if it was getting voltage, so I don't think it can be the blob of solder thing...

Second: Oops, I modified the code as I was playing around, and forgot what I ended with. So yes, it is actually coming back that the RTC IS running, and yet the time is not incrementing. Whether I put the RTC.adjust in the Setup or the Loop.

It'll take me more time than I have right now to get pictures, I'll try to do that later tonight.

Keith

keithwins
 
Posts: 10
Joined: Sat Jun 12, 2010 2:55 pm

Re: No RTC Luck on Datalogger shield

Post by keithwins »

I just added a quick check and reloaded the code, and it definitely asserts that the RTC is running, but it is still not incrementing.

Code: Select all

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 RTC;

void setup () {
    Serial.begin(57600);
    Wire.begin();
    RTC.begin();

  if (!RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }

}

void loop () {
  if (!RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    //RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  else Serial.println("RTC is running!");
  
    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.print(now.second(), DEC);
    Serial.println();
    
    Serial.print(" since 1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");
    
    // calculate a date which is 7 days and 30 seconds into the future
    DateTime future (now.unixtime() + 7 * 86400L + 30);
    
    Serial.print(" now + 7d + 30s: ");
    Serial.print(future.year(), DEC);
    Serial.print('/');
    Serial.print(future.month(), DEC);
    Serial.print('/');
    Serial.print(future.day(), DEC);
    Serial.print(' ');
    Serial.print(future.hour(), DEC);
    Serial.print(':');
    Serial.print(future.minute(), DEC);
    Serial.print(':');
    Serial.print(future.second(), DEC);
    Serial.println();
    
    Serial.println();
    delay(3000);
}

keithwins
 
Posts: 10
Joined: Sat Jun 12, 2010 2:55 pm

Re: No RTC Luck on Datalogger shield

Post by keithwins »

Hmmm, actually, this is a little more perplexing than I thought.

I copied the code right off LadyAda: there is a section that tries to compute/print a date/time 7 days & 30 seconds into the future. Well, the computation is way off (by 43 years and 14 seconds). It's the 14 seconds that confused me... Even if there's confusion between hex and decimal going on, I don't see where 14s can come from...

And in any case, RTC is asserted as running, but there's no incrementation.

Keith

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: No RTC Luck on Datalogger shield

Post by adafruit »

check that the crystal is soldered in right, and that the battery is making good contact (check all the solder joints and redo them)

keithwins
 
Posts: 10
Joined: Sat Jun 12, 2010 2:55 pm

Re: No RTC Luck on Datalogger shield

Post by keithwins »

Solved.

I built my other Data Logger shield, and it didn't work either. Exactly the same issue.

So I changed from using my Mega1280 to a Duemilanove 328, and both of the worked immediately. Why exactly I didn't think of doing that earlier is beyond me. Thanks for people's helpful thoughts.

Keith

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

Re: No RTC Luck on Datalogger shield

Post by adafruit_support_bill »

The Mega requires a different i2c library to work with the logger:
http://forums.adafruit.com/viewtopic.ph ... ega#p84759

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

Return to “Arduino Shields from Adafruit”