I2C Adapter / 16*2 LCD

Dear Community

I have the following problem: I am using an arduino micro, attached to a 54 matrix keypad and a 162 LCD display through an i2c adapter. Initially, everything works well, but after a couple of mi utes, the lcd starts displaying garbage. Sometimes, switching it off and on again does the trick, but for some reason that doesnt work anymore. However, I am almost sure there is no issue with the code, since the programme runs smoothly on my arduino uno for hours.

I am not using any resistors: I connected the 4 i2c pins to the arduino.

Do you have any idea what could be wrong/what I should perhaps try/further test?

Thank you so much for your help!

Alex
Do you have

The I2C adapter should be fine. The photo is unclear but it "looks" as if it contains 4k7 pull-up resistors (472).

I would be more worried by your keypad hardware and software.

Please paste / attach your sketch. A photo of your wiring. Post a link to any third-party libraries that you have used.

David.

Dear David,

Thank you so much for your reply!
I have attached a copy of the sketch and the libraries for the keypad and the lcd.

In terms of the wiring, I have connected GND and VCC to GND and 5V, on the Arduino, SDA and SCL to pins 4 and 5 and the keypad to pins 2 to 11. The wiring must be correct, since it was working perfectly fine for some time, but then it stopped working. Strangely, on another LCD the same setup with the same wiring (Arduino and keypad) was working again.

Thank you so much for your help!

Best
Alex

Test1.ino (41 KB)

Keypad-master.zip (30.5 KB)

LiquidCrystal_V1.2.1.zip (485 KB)

SDA should be connected to A4 on a Uno. (4 is a digital pin)
SCL should be connected to A5 on a Uno

If you use the dedicated I2C header pins on the 10-way header, it should work on a Uno, Leonardo, …

I suggest that you choose better colours for your jumper wires. e.g.
VCC=Red, GND=Black, …

It is always wise to one module at a time with the example sketches from the relevant library.
e.g. just try the LCD by itself.

David.

david_prentice:
If you use the dedicated I2C header pins on the 10-way header, it should work on a Uno, Leonardo, ...

Not necessarily.
On Leonardo SDA is digital pin 2 and SCL is digial pin 3.
Both of these seem to be being used in the sketch.
So if a Leonardo is being used, that is definitely an issue as pressing certain buttons will short out the i2c bus.
Worst case a pin has been damaged from this.

WCP1992,
If you want an easier to install & use lcd i2c library, you could consider my hd44780 library.
It will auto locate the i2c address and automatically figure out the pin mapping.
It is available in the IDE library manager.
It also includes a diagnostic test that will test your I2c signals as well as the internal RAM of the LCD.
You can read more about it here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
The i/o class is hd44780_I2Cexp
The diagnostic sketch is called I2CexpDiag.
It does not conflict with any other LCD library so you don't need to uninstall any existing LCD library to try it.

--- bill