Re: Random i2c errors, need help to stomp them out please!

Hi all . First of all excuse my english ,it is not my mother language.

I have an rtc ds1307 connected to a breadboard and then to the mega . Sda,scl with 4.7k resistors and another sensor in the I2C. Powering from an ATX PS 5V to the 5V line (In this case works better than the Vin,I don´t know why ) .

I was facing problems in sda line when the RTC isn’t connected staright on the arduino. Plugging it in the breadboard was failing and sending 165:165, or just nothing .

I connected before the capacitor in the Vcc line ,but it didn’t change anything . But it starts working when I connect the oscilloscope !!

I always follow Nick Gammon 's advices and tips :smiley: , but this time I couldn’t make the RTC works until I put and 1M pulldown resistor and 1uF electrolytic capacitor from SDA to GND.
Do I am making something wrong ? Are there another better solution that I should try?

Thanks for all .

Is the RTC gnd connected to the Arduino Gnd?

You should also start your own topic vs tagging onto one that is 4+ years old.

ATX 5V to 5V is correct. Vin feeds the 5V regulator, you will not see 5V coming out of the regulator.

What is the other sensor on the I2C bus ? It must be a 5V sensor and not a 3.3V sensor.

The Arduino Mega 2560 has already 10k pullup resistors to 5V. In most cases that is enough pullup.

Do you use wires or cables for the I2C bus ? Could you make a photo of your project ? Some breadboards have bad contacts.

I have looked at I2C signals on oscilloscope, rise time with 10K pullup is terrible. 4.7K is much better.

A capacitor from SDA to ground should kill the signal completely. There’s also no reason for a pulldown as that’s what the logic switching does, if it’s working correctly. I use 2K2 pullups for a typical layout as it shows a good clean waveform.

Got any power supply decoupling on the power rails of those chips.

A 1uF cap would normally stop an I2C from working so you must have some other fault like a bad ground connection.

The DS1307 is very flaky on the I2C line. It does not work at all when used with the Wifi101 shield. Remove the shield, the DS1307 works. Put the shield in place, the DS1307 fails. The DS3231 is much more robust.

Like you, I also found that some communication with the DS1307 worked when an oscilloscope was used to read SDA. Presumably, the probe capacitance was an influence.

CrossRoads: I have looked at I2C signals on oscilloscope, rise time with 10K pullup is terrible. 4.7K is much better.

The rise time spec for I2C on the DS1307 is 1000 ns. A 10K resistor will allow 45 pf on the line and still meet the spec. I know this because I recently went through the exercise when my DS1307 was failing. More than 45 pf on the line would be unusual. Just sayin'.