Lcd 20x4 i2c to leonardo

hwello, I am trying to connect an LCD 20x4 to my Leonardo, the problem is it is not printing anything. I've tried an I2C scanner and found its address at 0x27, but when I try to print something, the screen won't display anything. The same code works on my 16x2 LCD, so I'm thinking it's a hardware issue. But, if I send a code to get the LCD screen to flash repeatedly, it will. So, is it the code or just the screen? The screen turns on, but no matter how I adjust the potentiometer on the back, nothing changes. I've looked at the other posts to try and fix this issue, but to no success. Any help is appreciated.
The code I'm using is:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

// Set the address of the LCD module
#define LCD_ADDRESS 0x27  // Change this to your LCD address if different

// Set the dimensions of your LCD (columns x rows)
#define LCD_COLUMNS 20
#define LCD_ROWS 4

// Initialize the LiquidCrystal_I2C library with the LCD address and dimensions
LiquidCrystal_I2C lcd(LCD_ADDRESS, LCD_COLUMNS, LCD_ROWS);  

void setup() {
  // Initialize the LCD
  lcd.init();                      
  // Turn on the backlight
  lcd.backlight();
  // Print "Hello, World!" at column 0, row 0
  lcd.setCursor(0, 0);
  lcd.print("Hello, World!");
}

void loop() {
  // Empty loop since we're not continuously updating the display
}

Code looks ok. You say this exact same code also work with the 16x2 LCD if you change only the LCD_ROWS/COLUMNS values? That LCD also has an i2c backpack?

Post a schematic and some bright, clear photos of the circuit.

I agree it appears at this stage to be a faulty LCD.

Hi, I don't have any schematics, as I am relatively new to this whole thing. Here is a photo of the wiring and a photo showing that the LCD screen is working.


Have you got SDA & SCL swapped there?

scl to d3 and sda to d2, right?

Yep. Is that how you have connected them?

yes

Are you sure?

I think so, and to check I switched them around and it still did not work

Ok.

I was looking at the white and purple wires in your photos, and they looked swapped. But I guess i2c scanner would not have recognised the backpack if they were swapped.

So I think the backpack is ok but maybe the display itself may be faulty.

Make try re-soldering the connections between the backpack and the display in case there is a dry solder joint or something.

It could be that the I2C expander is wired to the LCD differently than the library expects.

As a test, install the hd44780 library by Bill Perry in the IDE's library manager, then run the example sketch File > Examples > hd44780 > ioClass > hd44789_I2Cexp > I2CexpDiag, that will show a lot of diagnostic information in the serial monitor.

1 Like

I have already purchased another LCD because my solder tip is dirty and I suck at soldering. But thanks for confirming my suspicion.

ok i will try that in a bit and get back to you

Maybe you could try the other i2c connection ?

OK, I have 2 LCD 20x4 i2c screens, the first where the screen only turns on and does not print anything. This one says that it might be a soldering problem. The second LCD says it works but the screen is not as bright as the first LCD. I even adjusted the potentiometer and still too dark. I tried uploading the same code to print Hello World to the second LCD, but no success again. So if the second LCD is working according to the code, the Arduino recognises the I2C address, but it's not printing anything, then it must be the code right?

Another I2C connection? Like defining new pins on the Arduino as the SCL and SDA??

The potentiometer controls the contrast, not the brightness. Brightness is usually fixed, depending on the LED backlight of the particular display and a dropping resistor. The two-pin header with the jumper is used to disable the backlight when the jumper is removed.

Does the I2CexpDiag sketch display anything on the LCD? It should.
Try the I2CexpDiag sketch with your working 16x2 display. The pin mapping between the I2C backpack and the LCD should be shown in the serial monitor, write that down for the 16x2 display, and compare with the results from the 20x4 display. The LiquidCrystal_I2C library assumes a common mapping between the I2C backpack and the LCD, not all displays are wired that way, I'm thinking that may be your problem.

yea you are right, for the 16x2 it does display values, but not the 20x4 does not

i2c

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.