setCursor(...) doesn't work with 20 x 4 LCD display

Re this sketch.

//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd 
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Hello, world!");
  lcd.setCursor(0,1);
  lcd.print("Ywrobot Arduino!");
   lcd.setCursor(0,2);
  lcd.print("Arduino LCM IIC 2004");
   lcd.setCursor(0,3);
  lcd.print("Power By Ec-yuan!");
}


void loop()
{
}

Hello, world! END
IIC 2004Arduino! END
Arduino LCM END
Ec-yuan! END

If I comment out all the calls to setCursor(....) then I get:

Hello, world!YwrobotEND
IIC 2004Power By ECEND
!Arduino LCMEND

I can't make heads or tales of what is going wrong here.

The 20 x 4 LCD came without one of those parallel to I2C converter modules and I purchased these separately and add them to the LCDs.

Tried the same thing with a different LCD library.

The output from the following sketch is...

lcd.setCursor(0,0) and lcd.setCursor(0,1) have the expected effect on lines 1 and 2 of my LCD.

But lcd.setCursor(0,2) result in the text "orld!" displayed on line 3 starting at column 9
And lcd.setCursor(0,3) result in the text "orld!" displayed on line 4 starting at column 9

Has anyone else had this problem with 20 x 4 LCD displays?

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

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 4);

void setup()
{
	// initialize the LCD
	lcd.begin();

	// Turn on the blacklight and print a message.
	lcd.backlight();
  lcd.setCursor(0,0);
  //lcd.setCursor(0,1);
  //lcd.setCursor(0,2);
  //lcd.setCursor(0,3);
  lcd.print("Hello, world!");
}

void loop()
{
	// Do nothing here...
}

I copied your code in the OP exactly as is, compiled using MiniCore and uploaded to a 328P bare bones (external 16MHz crystal) on a breadboard. I use a 20x4 LCD on the 328 for debugging, so had it all setup.

The LCD was a stand alone to which I added the I2C interface - like you.

My screen showed:

So I would guess you probably have a hardware problem somehow, the code is fine.

The Readme.md file for my copy of the LiquidCrystal_I2C library says "# LiquidCrystal_I2C ver 1.1.3". I do not know how up to date that is - it works so I do not touch. I use Arduino IDE Ver 1.8.10.

Willem

Willem43:
I copied your code in the OP exactly as is, compiled using MiniCore and uploaded to a 328P bare bones (external 16MHz crystal) on a breadboard. I use a 20x4 LCD on the 328 for debugging, so had it all setup.

The LCD was a stand alone to which I added the I2C interface - like you.

My screen showed:

So I would guess you probably have a hardware problem somehow, the code is fine.

The Readme.md file for my copy of the LiquidCrystal_I2C says "# LiquidCrystal_I2C ver 1.1.3". I do not know how up to date is - it works so I do not touch. I use Arduino IDE Ver 1.8.10.

Willem

I notice you don't have 4 pins of the parallel to i2c module soldered to the LCD panel. Why?

If I remember correctly, from the diagrams for the LCD and the I2C interface, they are not used.

My arguing is that if I ever need to change the interface, the least number of pins I need to un-solder the better.

I did the same on a 16x2 LCD and I2c interface and they all work correctly.

Willem.

Willem43:
If I remember correctly, from the diagrams for the LCD and the I2C interface, they are not used.

My arguing is that if I ever need to change the interface, the least number of pins I need to un-solder the better.

I did the same on a 16x2 LCD and I2c interface and they all work correctly.

Willem.

Any idea if the fact that I have these pins connected through is likely to be the source of my problems?

Makes no difference whether D0-D3 are connected or not.

So I have absolutely no idea why these screen won't work.

Think it might be easier in the long run to bin them and just by some with the i2c module already attached!

I would not have thought so. There is no way to guarantee that they will not make contact even when not soldered, so I would think soldering them would not cause a problem.

In any case, all the pictures on the web shows all pins soldered - so it must be OK.

What I find strange is that it seems as if information is actually sent to the display, it does communicate - it just seems to get some of it wrong, mostly the positioning. Do you only have the one display?

Willem.

[Edit] A bit slow in responding.

Willem43:
I would not have thought so. There is no way to guarantee that they will not make contact even when not soldered, so I would think soldering them would not cause a problem.

In any case, all the pictures on the web shows all pins soldered - so it must be OK.

What I find strange is that it seems as if information is actually sent to the display, it does communicate - it just seems to get some of it wrong, mostly the positioning. Do you only have the one display?

Willem.

[Edit] A bit slow in responding.

No I have another that I will try.

There are many different "LiquidCrystal_I2C" libraries. Not sure which one you are using, but some of them have issues.

I would suggest that you install the hd44780 library (available in the IDE library manager)

The i/o class for that type of backpack based device is hd44780_I2Cexp
Then run the I2CexpDiag sketch under that i/o class.

It will test the LCD memory to see if there are any issues.

You could also run the LineWrap sketch to watch how characters are written to memory to see if there are any issues.
You will want to modify the sketch to use 20x4 instead of 16x2 to see how it fills all the positions on your display.

There is lots of documentation included with the hd44780 library under the Documentation sketch.
You can also read more about it here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library

--- bill