I am using an Arduino Mega 2560 board have an LCD and a real time clock on the I2C. At one time it was working. Now the RTC will not initialize the LCD works just fine. If I unplug the LCD the RTC works? Anybody got an idea what I am doing wrong. Here is some of the code I am using:
I ran the scanner and had an interesting thing happen. With both the RTC and the LCD plugged in I only saw the 0X3F address of the LCD. I unplugged the LCD and the RTC address 0X68 showed up. I plugged the LCD back in then both addresses showed up?
I attached a couple of pics of the wiring.
Thanks for the help!
Bill
Thanks for the photos, everything seems fine as far as I can tell.
That single tyrap can't cause so much trouble.
We have to dig a lot deeper.
The combined pullup resistor of the I2C could be too high or too low. Or there are some bad contacts. Or a bug in the libraries or sketch. Like Hackscribble, I think the pullup resistors for the I2C bus is the first thing to look into.
Do you have a link to the DS1307 and the LCD modules ?
The Arduino Mega has onboard 10k pullup resistors, plus internal 50k.
If the DS1307 module has 4k7 pullup resistors, it might still be okay, but if they are 2k2, it might be too low.
With a multimeter, it is possible to measure the pullup resistors. Load the Arduino with an empty sketch (empy setup() and loop() functions or the blink example), and measure the shortcut current of SDA to GND and the shortcut current of SCL to GND. If they are about 1mA (0.5 to 2mA), they are okay.
Do you use the newest Arduino IDE 1.0.6 or 1.5.8 BETA ? And the newest versions of the libraries ?
Or do you perhaps allocate too much ram with an array of variables or many Serial.print strings ? Could you show the whole sketch ?
I have found a work around but I do not understand why it works. I simply move some code around so the RTC is initialized before I do any thing with the LCD. So far it has worked every time I reset or restarted the Mega. If I have issues again I will test for the pull up resistor.
Thanks for all your help!
Bill
There were old bugs with the Arduino Mega 2560 board, and shifting around the memory was a workaround for it. Do you use a Mega 2560 clone from Ebay or an older board ?
Allthoug I think this is not the old bugs, the old bugs can be fixed by using the newest Arduino IDE 1.0.6 or 1.5.8 BETA and also burning a new bootloader.