RTC initialization on Arduino UNO with data logging shield

Hi,

I try to set and read RCT DS1307 on data logging shield but after upload the program I read on serial monitor wrong date and time.

RTC is NOT running!
2165/165/165 165:165:85
2165/165/165 165:165:85
2165/165/165 165:165:85
2165/165/165 165:165:85
2165/165/165 165:165:85
2165/165/165 165:165:85
2165/165/165 165:165:85
2165/165/165 165:165:85
2165/165/165 165:165:85
2165/165/165 165:165:85
2165/165/165 165:165:85
2165/165/165 165:165:85
2165/165/165 165:165:85

and the program:

#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!");

}

rtc.adjust(DateTime(2015,5,28,10,50,0));
}

void loop () {
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();

delay(3000);
}

I thing I2C don't work because without Logging board I receive de same data.
Please help!!

Which logging shield did you buy?

I thing I2C don't work because without Logging board I receive de same data.

Here is I2C scanner code which will test if the ds1307 RTC is seen on the I2C bus.

First, run the code with nothing attached to your Arduino confirm that is reports "Found 0 devices" and does not hang up. If it hangs up and does not report back, then there is a problem with the Arduino.

Second, attach your shield and rtc and see if it reports finding Address 0x68.

If it does not find this address, there is likely a bad connection or a defective device.

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (115200);

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

I just want to say I am having a lot of trouble using what appears to be the same shield. Adafruit data logger. All I want to do is set the correct time, Download the code from their web site. First attempt was only off 2 days. ?? After that it kept setting itself to the same time that appeared in the code. So I changed the time in the code. Now it will set 1 week in the future. Adjust the clock on my computer and it changes the year to 2014 and the other info is not correct. ReAlly?? I have used two computers, Windows 8 and Windows 7 same results. JC all I want to do is set the clock. LOL

Are you using the "new and improved" Adafruit Data Logger Shield? Are you following the tutorial?

Do you have the battery installed? The instructions say "You MUST have a coin cell installed for the RTC to work, if there is no coin cell, it will act strangly and possibly hang the Arduino so ALWAYS make SURE there's a battery installed, even if its a dead battery."

Thank you

I use I2C scanner code post by cattledog and returns "Found 0 devices" without logging board and the same with logging board.
I check electrical conection and are OK. I ill try to use one osciloscope to view SDA and SCL signals, i thing the problem is in arduio board.

I use osciloscope and dont have any data on SDA ,SCL. Both are in Hight state (5V). Its possible to have a problem with library initialization. Its normal 5V on SDA end SCL?

Thank you!

Here's a link to Nick Gammon's excellent tutorial on the I2C buss.

It will show you what to look for in the scope when you send data.

You shold be able to determine if the Arduino is sending Data, and if the device is not responding with an ACK.
,
The 5V you are seeing is the effect of the pull up resistors--either the internal pullups turned on by the Wire library, or external ones you have added or that are on the data logger shield.