Serial 2004 20x4 LCD Module Shield displaying single charector

Hello I recent purchased this screen http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html

I have the screen somewhat working using the LiquidCrystal_I2C Library. It is connected to a Arduino Mega 2560 and the SDA and SCL pins are connected to the SDA and SCL on the Mega. However when I use the following code

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

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

void setup()
{
  lcd.init();                      // initialize the lcd 
 
  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("Hello, world!");
}

void loop()
{
  lcd.print("Hello");
  delay(1000);
}

It only prints out the first character of the phrase. I have tried a different phrase and it does the same thing. Prints "H"
Is the problem with the Library.
Any help appreciated Thanks

tom15:
Hello I recent purchased this screen http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html

I have the screen somewhat working using the LiquidCrystal_I2C Library. It is connected to a Arduino Mega 2560 and the SDA and SCL pins are connected to the SDA and SCL on the Mega. However when I use the following code

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

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

void setup()
{
  lcd.init();                      // initialize the lcd

// Print a message to the LCD.
  lcd.backlight();
  lcd.print("Hello, world!");
}

void loop()
{
  lcd.print("Hello");
  delay(1000);
}



It only prints out the first character of the phrase. I have tried a different phrase and it does the same thing. Prints "H"
Is the problem with the Library.
Any help appreciated Thanks

Sorry I have same problem it seems that the LCD.print only wright one "X" to get one more I have to set the lcd.setCursor(3,0); to next one
It may be the IED have read that some other have it to work in a other IED

Leave loop() empty while you are getting your LCD to work. Let us know what you see on the display.

Don

I tried leaving the loop empty but it does not help. Having the lcd.print("Hello"); in the setup just prints H out once on the screen, instead of continuous. If I spell out each letter by itself per command I can get it to display the word I want but that is a waste of time. Also the lines are messed up in the loop it fills one line then skips a line fills that, then returns to the line it skipped. Does any one what is wrong?

I can help with this part:

Also the lines are messed up in the loop it fills one line then skips a line fills that, then returns to the line it skipped. Does any one what is wrong?

Unfortunately there's nothing wrong with this behavior. It's a 'feature' of the LCD controller. For the full story follow the LCD Addressing link at http://web.alfredstate.edu/weimandn.

Now back to this:

I have the screen somewhat working using the LiquidCrystal_I2C Library.

Which library are you referring to? There are lots of them, all with the same name.

I suggest you try the 'New LiquidCrystal Library' by Francisco Malpartida. You can get it here: --> https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

Don

floresta:
Which library are you referring to? There are lots of them, all with the same name.

I suggest you try the 'New LiquidCrystal Library' by Francisco Malpartida. You can get it here.

It's just a pity that the bloody-mindedness of the Arduino team is here exhibited in not including this most important library in the ever-bloated distribution of the IDE, preferring to include four versions of the useless one! :roll_eyes:

Or have I missed something?

Minutes before I also opened a topic regarding this problem and wrote how i fixed the problem for me.

On my side i found this issue after upgrading from 1.6.1 to 1.6.6. After downgrading to 1.6.5 everything was OK again.

It work for me to at downgrade 1.6.5 . :slight_smile:
The may be a path for this... can we hope

No downgrade, you have other solution.

  1. Use New LiquidCrystal Library by Francisco Malpartida as suggested by floresta .
  2. Open issue to maintainer of LCD I2C library you use, it is easy fix.
  3. I fix one of them ( they all have same name and code looks same ) - it works fine with 1.6.6. Just replace old one with the attachment lib.

LiquidCrystal_I2C_for_IDE_1.6.6.zip (8.52 KB)

Guys,
This sounds like it is possible that it is an issue not related to a library misconfiguration.
The posters are saying that the EXACT same code and sketch works with 1.6.5 and doesn't work with 1.6.6
the symptom being that only the first character shows up on the LCD with 1.6.6

If this is the case, then it is possible that there could be an I2C issue in 1.6.6

common_ground, you are saying that you have modified a library to make it work with 1.6.6 ?
What was the modification?

--- bill
NEVERMIND.
I see the problem.
While it is technically an issue in the lcd library, it is caused by a change in the IDE Print class code.
Team arduino.cc has decided to change the write() function to allow asynchronous i/o.
The way that they have done this is VERY bad and has MANY issues with print() functions.
I'll go jump on them and try to explain why they simply can not do the code this way.
i.e. you can't break print() functions. Those must be synchronous and not return until all their i/o is completed unless you have a class option to enable/disable it (which they don’t').

bperrybap:
What was the modification?
--- bill

New IDE 1.6.6 Print function is different from previous versions , explained here :
LCD write() functon changes

Just small modification, but solve big problem.

common_ground:
New IDE 1.6.6 Print function is different from previous versions , explained here :
LCD write() functon changes

Just small modification, but solve big problem.

I saw that and while this specific issue was caused by some broken code in an LCD library,
there is a larger issue related to partial i/o in the Print class print() functions that needs to be dealt with.
I posted lengthy post in that thread about it.
--- bill

Ok guys thanks for all the feedback using an older edition of the Arduino IDE solved the displaying 1st letter problem however it did not solve the jumping lines problem. Common_Ground's Library is awesome however it also has not solved the line jumping problem. Does anyone know how to fix this last problem? Really appreciate all the advice. As a I said above the display fills the first line skips and fills the third goes back to the second and then fills the fourth. Thanks

tom15:
As a I said above the display fills the first line skips and fills the third goes back to the second and then fills the fourth.

That is the way memory is laid out in the hardware. See Don's post in post #4:
http://forum.arduino.cc/index.php?topic=359482.msg2479296#msg2479296

Read the link in Don's post about how memory is mapped to the LCD screen.
It is not a s/w bug. That is the way the hardware works.

You can't fill the screen using linear memory addresses.
You have to use the cursor positioning calls to set the cursor to the beginning of each line.
When you do that, the library s/w will do the correct conversion to get the proper memory address for the line you want.

--- bill

Understood and thanks lcd.setCursor(xx,xx);

tom15:
... it also has not solved the line jumping problem. Does anyone know how to fix this last problem?

So in short, it's not a problem at all!

This (variety of) display is simply not suited to displaying freehand text such as I type here for the discussion board. There is simply no need for line wrap - to say nothing of word wrap - or indeed (vertical) scrolling. Nor is horizontal scrolling particularly appropriate either though there are some facilities for this.

All you will need to do with this display, is to have a piece of information displayed in a given position on the screen. The fact that you need to carefully plan on where that piece of information goes, what size it is, how it might interact with other information, even how it might interact with information previously written in the same place (which happens when you print a smaller number over a previous larger version) is just part of the process. "Line Feed" is meaningless on such a display - if you even attempt to send such codes, you get only a character from the PCG RAM.

lcd.setCursor(); is your friend. :grinning:

(We need a proper tutorial on this to point to, don't we?)

tom15:
Hello I recent purchased this screen http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html

I have the screen somewhat working using the LiquidCrystal_I2C Library. It is connected to a Arduino Mega 2560 and the SDA and SCL pins are connected to the SDA and SCL on the Mega. However when I use the following code

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

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

void setup()
{
 lcd.init();                      // initialize the lcd

// Print a message to the LCD.
 lcd.backlight();
 lcd.print("Hello, world!");
}

void loop()
{
 lcd.print("Hello");
 delay(1000);
}



It only prints out the first character of the phrase. I have tried a different phrase and it does the same thing. Prints "H"
Is the problem with the Library.
Any help appreciated Thanks

I have been having the same problem. A character prints in place of what would be the 2nd character in the string that appears to look like 3 stacked lines (like some "menu" icons.)

I opened and read the LCD (ect) .H file. and found the calls that can be made. I tried inserting lcd.clear, lcd.blink, lcd.home, etc. and all seem to work.
I can move the cursor around on the display but cannot. Println seems to cause the line to move to the next down. But nothing about this makes any sense. I got this display from Amazon as a replacement for the first one I got from them that behaved exactly the same. I am new to Arduino but have lots of prior BASIC experience am not frighten by technology. Finding a solution to this is not a life or death matter. I am just tenacious when confronted by something that doesn't work right.
Any hints for a solution would be appreciated
Mike :slight_smile:

mike_flood,
You have a broken lcd library. It is not returning the proper return value from write() so the print() code that calls it thinks that there was an error and throws away all the remaining output after the first character.

To fix it, update your library library, or use a different library.

--- bill