DS1307 crashes arduino

Hi, i'm trying to set up a simple RTC module. I've got 2 Uno's and a whole bunch of mini's, and 4 of the RTC modules. I've tried the example code

and

The result is the same, when the arduino is powered up with the RTC module connected it hangs instantly and needs to be reset.

If the battery is removed from the RTC the arduino will start and I can get the "RTC is NOT running!" error in the serial monitor. I have one DS1307 module from adafruit and 3 more from eBay and they all display the same fault. I've tried powering the module from a separate 3v supply instead of the battery as mentioned elsewhere but any positive voltage on the battery terminal will hang the arduino.

Can anyone shed any light on how to troubleshoot this? (or recommend a better RTC than the DS1307, apparently the DS3231 keeps time more accurately, but is it more reliable?)

thanks in advance

EDIT: Turns out even connecting the I2C pins without the power pins will hang the arduino.

The result is the same, when the arduino is powered up with the RTC module connected it hangs instantly and needs to be reset.

Can you run the standard blink sketch with the RTC module attached but without any calls to it?

When you run this i2c scanner program, does the sketch return a value without a battery and hang when one is installed?

// 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

Thanks for replying :slight_smile:

Can you run the standard blink sketch with the RTC module attached but without any calls to it?

Yep, it's blinking just fine.

When you run this i2c scanner program, does the sketch return a value without a battery and hang when one is installed?

This code doesn't compile:

Arduino: 1.6.10 (Windows 10), Board: "Arduino/Genuino Uno"

cc1QGEKz.ltrans0.o:(.text.startup+0x304): undefined reference to `loop'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

no idea what to do about that

Sorry :frowning: Cut and paste error. Missed the last line

add at the end of the sketch

void loop() {}

void loop() {}

Of course, sorry, I'm a noob.

With no device:

I2C scanner. Scanning ...
Done.
Found 0 device(s).

With the RTC and no battery:

I2C scanner. Scanning ...
Found address: 80 (0x50)
Done.
Found 1 device(s).

With the RTC and battery installed:

I2C scanner. Scanning ...

I left it a few minutes, but I don't think it's gonna do anything. I tried the Adafruit one and a Tiny RTC one and they do the same thing.

I2C scanner. Scanning ...
Found address: 80 (0x50)
Found address: 104 (0x68)
Done.
Found 2 device(s).

This is what you should be seeing, both with and without a battery when connected to arduino 5v/gnd.

The 0x50 is the address of the eeprom on the module and the 0x68 is the address of the rtc.

The fact that you read no devices with nothing connected indicates that the Arduino board itself does not have any SDA/SDL shorts.

The fact that you see 0x50 indicates that you have the SDA/SCL correctly wired between the Arduino and the module.

How are you supplying 5v to the module?

Somehow the rtc is not seeing 5v. When I connect my module to 3.3v the scanner shows

I2C scanner. Scanning ...
Found address: 80 (0x50)
Done.
Found 1 device(s).

I was surprised that the EEPROM was seen on the i2c bus with the lower voltage, but it was. For now, focus on why the rtc is not seeing 5v.

It's just connected to the 5v pin on the arduino. I will measure the voltage on the Vcc pin of the module when I get home and report back.

Thanks for the help mate ^^

Are you using a battery to power the Arduino? USB? Wall wart?

I've got a 12v/5A power supply connect to the arduino's barrel jack. The voltage on the actual jack is 12.12v. The arduino's 5v rail measures~4.94v, and the RTC module has 4.94v on its Vcc pin and on pin 8 of the DS1307 chip.

I've got 2 Uno's and a whole bunch of mini's, and 4 of the RTC modules.

I tried the Adafruit one and a Tiny RTC one and they do the same thing.

Do all Arduino's and all modules display the same behaviour with the scanner program? --- the scanner finds 0x50 and not 0x68 but does not hang when there is no battery installed?

Yes all four modules behave exactly the same, I've never seen 0x68 with any combination. I've ordered some DS3231 modules in the meantime to see if they work any better.

EDIT: The four modules also show the correct supply voltage, I'm using very short jumpers and I've checked them for continuity.

I've ordered some DS3231 modules in the meantime to see if they are any better.

Let us know how it works out. For now, I'm out of ideas. The ebay modules could be defective, but the adafruit one should work.