RTC3231 with I2C error when connect with Ethernet shield

Hello I’m a newbie to arduino. I would like to do a very simple job about connecting SD card reader to the arduino UNO R3 by Ethernet shield and I would like to retrive a time stamp from DS3231 module.

First, I tried connect DS3231 module with normal I2C(no ethernet shield) with this code and it workes fine.
But after I pushed the ethernet shield on top the arduino and connect wires same as the first time–>It told me “Unable to sync”.

So I check the ethernet function on board->it’s normal. I check SD card function->it’s normal. I check Ethernet and SD card in the same time->They’re normal. But I still can not get time from my DS3231.
I’ve tried to find the conflict problems among Ethernet shield and I2C …I found some problems but not clearly help me in this case.

I plan to buy a new microSD card module alone and try connecting again->however I still can not use ethernet in the same time anyway. :cold_sweat: :~

TimeRTC.ino (1.34 KB)

Perhaps the initialization in a library is somehow not okay.
The hardware should have no conflict at all. Ethernet and SD use SPI, and the DS3231 use I2C.
Do you use a very cheap and thin usb cable ? Perhaps there is not enough power, since the Ethernet Shield is power hungry.
Try an external power supply to the barrel jack connector.

Can you add a file to your project and turn the i2c_scanner into a function ?
http://playground.arduino.cc/Main/I2cScanner
Somewhere in this code is the function i2c_scanner() : http://playground.arduino.cc/Main/ShowInfo
Run the i2c_scanner before the setSyncProvider and after that.
Perhaps you need a delay there.

You can also take rigorous measures. Use NTP for time syncing, and try to find DS3231 code that works on its own. Try to run all three (Ethernet + SD + RTC). I'm sure that will work.

Do you have a 4.7k pullup resistor on both SDA and SCL?

Pete

Dear Peter_n,

Peter_n:
Perhaps the initialization in a library is somehow not okay.
The hardware should have no conflict at all. Ethernet and SD use SPI, and the DS3231 use I2C.
Do you use a very cheap and thin usb cable ? Perhaps there is not enough power, since the Ethernet Shield is power hungry.
Try an external power supply to the barrel jack connector.

Can you add a file to your project and turn the i2c_scanner into a function ?
http://playground.arduino.cc/Main/I2cScanner
Somewhere in this code is the function i2c_scanner() : http://playground.arduino.cc/Main/ShowInfo
Run the i2c_scanner before the setSyncProvider and after that.
Perhaps you need a delay there.

You can also take rigorous measures. Use NTP for time syncing, and try to find DS3231 code that works on its own. Try to run all three (Ethernet + SD + RTC). I’m sure that will work.

Thanks for your kind advise. I try I2C scanner->It shows No I2C device found!!
I add one switching power to the board but it doesn’t help.

el_supremo:
Do you have a 4.7k pullup resistor on both SDA and SCL?

Pete

No I don’t. Should I do it?

Thank you all,

I think this thing is not common so I use the multimeter to test a conductivity of pin between arduino and Ethernet board and then bingo ->A4 discontinuity so this is a hardware problem I will try to fix it asap. Thanks.

If that doesn't fix things, you should add the pullups.

Pete

el_supremo:
If that doesn't fix things, you should add the pullups.

Pete

It has been fixed with new wires. However, should I add pullup resistors all the time?

I2C requires pullups on SDA and SCL. If they aren't already there you have to add them.

Pete