Why did my 4th I2C build failed (and why setClock fixed it)?
Controller: Arduino Mega 2560 (Elegoo revision).
Peripherals: Dual 20x4 LCDs with I2C backpacks.
The Issue: I2C scanner would find both addresses, but the second display would be all square blocks text.
The "Magic Fix":
I dropped the I2C clock speed from the default 100 kHz to 10 kHz using Wire.setClock(10000);. Instantly, the "missing" display became stable and started rendering text perfectly.
The Theory:
We suspect the newer Mega boards or different batches of LCD backpacks have different electrical tolerances?
Questions for the Experts:
1. Which Library? I am currently using LiquidCrystal_I2C. Is there a more robust library (like hd44780 by Bill Perry) that handles bus errors or timing more gracefully?
2. Why the 4th build? My first three builds worked at the default speed. Just the luck of the draw with component tolerances?
3. The "Correct" Path: Is running at 10 kHz a valid long-term solution, or am I just masking a hardware failure that will bite me?
I heard that hd44780 Library wastes memory, is that true??
I do not claim it is better, on contrary, the HD44780 is I think the best library and
LiquidCrystal_I2C has features that the mine has not.
My lib has a different implementation (thus different timing) and if it works where LiquidCrystal_I2C failed it could point to a timing or implementation issue.
We thought the HD44780 library fixed it but when we installed it into the case, the screens flaked out again.
This time, I knew the code couldn't be to blame. The new library is so much nicer and made the screen renders smoother.
The wires that come with those screens aren't the best, so we made our own and sure enough, the screens worked reliably now. We did about an hour of testing and perfect rendering.