Maybe I picked the wrong Forum... I have a Problem with I2C locking up when the RTC module is powered off/on.
First, I have a custom PCB which piggybacks an Arduino Pro Mini onto the back of a 20x4 I2C display. The PCB also has a MOSFET, tied to Arduino pin 4, which is intended to turn the power to the peripherals (sensors, etc.) on and off on demand to save power.
Using used Nick Gammons I2C scanner with the LCD Display and the RTC/EEPROM attached I get the expected three Messages for all three I2C devices.
The cable attaching the RTC is about 6 inches long, ribbon cable, and I have placed Ground between SCL and SDA on the runs and 5V on the other side of SCL (of course, correcting the order at the RTC). I don't see how the cable could be my problem.
I modified Nick Gammons I2C scanner (temporarily) to turn peripheral power (pin 4) on/off. Setup turns it off, it gets turned on before entering the scan loop and turned back off when scanning is finished. It works fine if the RTC is attached straight to 5V. However, if I attach the RTC VCC to the switched 5V, I2C will lock up. Nicks Programm says "Scanning..." and never goes any further. No devices are reported and I don't get the "Done" message. Sometimes it scans once just fine then locks up, other times it locks up before scanning at all.
I added a delay(1000) after turning the power on and also tried adding a Wire.begin() after the delay. Nothing helps. I2C still seems to lock up.
Does anyone have an idea why turning the power off/on on the DS3231/AT24C32 module locks up the I2C?