I2C 20x4

i downloaded the "new liquid crystal 1.3.4" library from here: NEW LIQUID CRYSTAL 1.3.4 LIBRARY

using the following sample code frome here: SAMPLE CODE

/* YourDuino.com Example Software Sketch
 20 character 4 line I2C Display
 Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
 Connect Vcc and Ground, SDA to A4, SCL to A5 on Arduino
 terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include   // Comes with Arduino IDE
// Get the LCD I2C Library here: 
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include 

/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address


/*-----( Declare Variables )-----*/


void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);  // Used to type in characters

  lcd.begin(20,4);         // initialize the lcd for 20 chars 4 lines, turn on backlight

// ------- Quick 3 blinks of backlight  -------------
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on  

//-------- Write characters on the display ------------------
  // NOTE: Cursor Position: Lines and Characters start at 0  
  lcd.setCursor(3,0); //Start at character 4 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(2,1);
  lcd.print("From YourDuino");
  delay(1000);  
  lcd.setCursor(0,2);
  lcd.print("20 by 4 Line Display");
  lcd.setCursor(0,3);
  delay(2000);   
  lcd.print("http://YourDuino.com");
  delay(8000);
  // Wait and then tell user they can start the Serial Monitor and type in characters to
  // Display. (Set Serial Monitor option to "No Line Ending")
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Start Serial Monitor");
  lcd.setCursor(0,1);
  lcd.print("Type chars 2 display");  


}/*--(end setup )---*/


void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  {
    // when characters arrive over the serial port...
    if (Serial.available()) {
      // wait a bit for the entire message to arrive
      delay(100);
      // clear the screen
      lcd.clear();
      // read all the available characters
      while (Serial.available() > 0) {
        // display each character to the LCD
        lcd.write(Serial.read());
      }
    }
  }

}/* --(end main loop )-- */


/* ( THE END ) */

and yes, it is wired as stated to do so..

the unit i have is: |500x500 |500x500

so yes, gnd, 5v, a4, a5 connected properly library is in the arduino libraries folder.. but named as: I2C_20x4_LCD and yes i can see it in arduino IDE under EXAMPLES

so why am i angry? no matter what example code i use.. the lcd lights up but NOTHING is displayed.. yes i have tried playing with the contrast.. but that has nothing to do with it..

so can someone please tell me what i'm doing wrong?

There are two main reasons that cause nearly all the issues with that library. - incorrect installation - incorrect i2c address or pin mappings in the constructor.


As an alternative, I would recommend my hd44780 library package. It can offer a simpler "plug and play" solution. It is available in the IDE library manager so it can quickly and easily be installed from the IDE gui using the library manager. With other i2c LCD libraries you must specify the i2c address. Most libraries are also hard coded to work with backpacks that use a specific pin mapping between the PCF8574 and the hd44780 LCD display and if your backpack doesn't use that pin mapping, it won't work. A few libraries, like fm's NewLiquidCrystal library allow the sketch to configure the PCF8574 pin mappings and backlight control. If the pin mappings are not specified correctly, it will not work. The hd44780 library can auto detect everything, the i2c address, the pin mappings, and the backlight control. You can read more about it here: https://github.com/duinoWitchery/hd44780 And there is additional information in the wiki:https://github.com/duinoWitchery/hd44780/wiki

The hd44780 github page contains information about the library including installation instructions. Use the IDE library manager to install it as it is easier and faster than trying to do it manually or using the zip install. Also, by using the IDE library manager it ensures that the library is installed properly not to mention that you will also get the latest tested version of the library.

The library package includes support for several different h/w i/o interfaces used to communicate with the LCD module.

Each i/o interface has its own i/o class and its own set of examples. The examples for each i/o class are grouped together in a directory by the name of the i/o class. While all the examples are always available regardless of which h/w you actually have, using an example for an i/o class that is for different h/w will not work. It will compile but obviously will not work. The i/o class you will want to use for that backpack which contains an i2c i/o expander chip is hd44780_I2Cexp That i/o class includes a diagnostic sketch (I2CexpDiag) which will test the i2c signals and internal RAM of the LCD module to verify that the the library is properly communicating with the LCD module. It is useful to first run this sketch to verify that the library is properly talking to your backpack and LCD module. Read the instructions in the sketch for how to run it and what to expect on the serial monitor.

After running the diagnostic sketch, you can run and look at other sketches for the hd44780_I2Cexp i/o class like the HelloWorld sketch to see what header files need to be included and how to declare the lcd object.

The hd44780 library contains additional capabilities not available in other libraries like - return status to tell if API functions are not working correctly (usually do to i2c communication issues) - ability to enable automatic line wrapping - ability to read the display RAM or LCD status - faster than other libraries as Arduino can run in parallel with LCD commands/instructions

I would highly recommend first running the diagnostic skech I2CexpDiag to verify that everything is working, then you can run and look at the other examples included in the hd44780_I2Cexp i/o class (like HelloWorld) to see what header files need to be included and how to declare the lcd object.

--- bill

ty, i will look into tomorrow after work.. :)

Installation using Library manager (IDE 1.6.2 and later)

In the IDE, Simply click on [Sketch]->Include Library->Manage Libraries... Then search for "Extensible hd44780" to locate the library and install it. There is no need to uninstall or modify any other LCD libary that may have already been installed.

INSTALLED :)

now to get this thing to work..

That i/o class includes a diagnostic sketch (I2CexpDiag) which will test the i2c signals and internal RAM of the LCD module to verify that the the library is properly communicating with the LCD module.
It is useful to first run this sketch to verify that the library is properly talking to your backpack and LCD module.
Read the instructions in the sketch for how to run it and what to expect on the serial monitor.

After running the diagnostic sketch, you can run and look at other sketches for the hd44780_I2Cexp i/o class like the HelloWorld sketch to see what header files need to be included and how to declare the lcd object.

i uploaded… nothing happened… then uploaded the hello sketch… nothing happened… :confused:

The first thing you should be running is the diagnostic sketch to make sure everything is working. There is no point in running anything else until this is working.

BTW,, the library does not come with an example named "hello". There are several example sketches named HelloWorld.

Anytime you are using examples that come with the library you must use an example that is for the desired i/o class, hd44780_I2Cexp in your case.

The wiki explains this in a bit more detail.

--- bill

you must use an example that is for the desired i/o class, hd44780_I2Cexp in your case.

i ran that test and nothing happened :frowning:

Read the wiki

i did.. :/

it really shouldn't be this hard to get an lcd display to work..

i have the pins connected as they are to be.. gnd, 5v, A4,A5.. i have the library installed.. just about any lcd code should work.. but nope, this has to be complicated like everything else >:(

multiplexing several 7-segment leds was easier.. so was multiplexing 100 rgb leds.. but i can't get 1 freaking letter to display on a lcd screed????? so pissied off right now..

not like the parts are small enough to deal with it as it is.. but nooo.. let's throw in libraries and all sorts of complicated coding into the mix while we are at it and make the people that have less experience get discouraged.

this is all i get if i open the serial monitor running that test: https://ibb.co/gjTQSb - img hosted on imgBB

so done with this shit..

Ruffsta: i did.. :/

Perhaps, but if so, not very well. The wiki shows the exact sequence in the IDE to get to the proper example area for the hd44780_I2Cexp i/o class. The screenshot image that you had posted earlier, that you have now erased/removed, showed using the wrong sketches.

it really shouldn't be this hard to get an lcd display to work..

It isn't when using the hd44780 library package. Many people have used my hd44780 library package with their i2c LCD backpacks and it worked for them "out of the box".

i have the pins connected as they are to be.. gnd, 5v, A4,A5..

1) just saying you are using A4 and A5 doesn't say how they are connected to the SCL and SDA 2) It depends on which Arduino board you have. You never said which one you have and some use A4/A5 for i2c and others don't. That is why running the diag sketch is useful. It will print out lots of useful information that can help diagnose potential wiring, h/w, or s/w issues.

just about any lcd code should work..

That is where you are definitely wrong. In post #1 I explained some of the issues with various i2c backpack libraries. And that is why I recommend using hd44780. hd44780 offers "plug and play" capability for i2c lcd backpack devices to really simplify things.

so done with this shit..

ok, feel free to give up. My overall comment is that if you had read the hd44780 wiki a bit closer, you would have a working LCD.

--- bill

Look closely at the diag output. You said you are using A4 & A5 but A4 and A5 are not used for I2C. Fix your wiring.

--- bill

k... gnd, 5v, 20, 21..

blinks for a second and then goes blank.. as in no backlight or anything after the blink :/ some fix

2) It depends on which Arduino board you have. You never said which one you have and some use A4/A5 for i2c and others don't.

and yes i am using a mega2560 on com4..

Ruffsta: k... gnd, 5v, 20, 21..

blinks for a second and then goes blank.. as in no backlight or anything after the blink :/ some fix

some fix ? Hey, you were the one that came out swinging blaming the s/w for your h/w wiring issue.

If you want others to help you - like me, I suggest you take a step back and tone things down.

You have not adequately described what you have done, nor how it has affected the diagnostic output.

--- bill

gnd to arduino gnd vcc to arduino 5v SDA to arduino 20 SCL to arduino 21

installed the library via arduino mega2560 IDE

ran the diag test

newest serial monitor report: pic - hosted on imgBB

described what happens to lcd after the upload

so what am i not "adequately" describing now? :/

too early to say what i want it to say or do - tho i know what they are..

You know you can post serial monitor text to the forum rather than have to use photos on some other server. For others that may read this thread long in the future, it is usually better as it keeps all the information on the forum server.

What is happening now is that the i2c signals are working good enough to discover the PCF8574 chip, but there is some kind of issue between the PCF8574 chip and the LCD that is keeping the library from being able to properly identify the chip or its output port pin mapping to the LCD.

This is usually from some kind of soldering issue. Can you post some clear photos of your actual LCD module (both sides) so we can see all the soldering? (the soldering of all the components on the backpack PCB as well as the soldering of the 16 pin header pins)

--- bill

apparently it was the soldering.. it is now displaying :

LCD:0 (0x27) 00:05:10

and counting up


Serial Initialized

I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool

hd44780 lib version: 0.9.0

Reported Arduino Revision: 1.6.5

CPU ARCH: AVR - F_CPU: 16000000

A4: digital pin: 58 A5: digital pin: 59 SDA: digital pin: 20

SCL: digital pin: 21

Checking for required external I2C pull-up on SDA - YES

Checking for required external I2C pull-up on SCL - YES

Scanning i2c bus for devices.. i2c device found at address 0x27

Total I2C devices found: 1

Scanning i2c bus for all lcd displays LCD at address: 0x27 | config: P01245673H | R/W control: Yes

Total LCD devices found: 1

LCD Display Memory Test Display: 0 Walking 1s data test: PASSED

Address line test: PASSED

Each working display should have its backlight on and be displaying its #, address, and config information If display is blank, but backlight is on, try adjusting contrast pot

If backlight is off, wait for next test

Blinking backlight test: to verify BL level autodetection If backlight is mostly off but you briefly see "BL Off" on display with backlight on, then the library autodetected incorrect BL level

and the library cannot autoconfigure the device

Displaying 'uptime' on all displays

now all i need is a sample code to put what i want in each of the 4 rows.. all i see is a "linewrap" sample.. but that's not what i am looking for..

do you have a sample code of what i need to include and something for each row?

like:

#include 
#include                        // main hd44780 header
#include  // i2c expander i/o class header

hd44780_I2Cexp lcd; // declare lcd object: auto locate & config exapander chip

// LCD geometry
const int LCD_COLS = 20;
const int LCD_ROWS = 4;

void setup()
{
    // Print a message to the LCD
    lcd.print("Hello, World!"); // 1st row
        lcd.print("welcome"); // 2nd row
    lcd.print("it's a nice day!"); // 3rd row
        lcd.print("How are you?"); // 4th row
}

void loop()
{

}

i don't want anything that absolutely doesn't need to be there.. just a simple sample code

UPDATE: i wrote my own.. works, dunno if it's perfect.. but it works.. need to learn how to blink and typewriter with/without blinking cursor samples..

#include 
#include                        // main hd44780 header
#include  // i2c expander i/o class header

hd44780_I2Cexp lcd; // declare lcd object: auto locate & config exapander chip

// LCD geometry
const int LCD_COLS = 20;
const int LCD_ROWS = 4;

void setup()
{


  int status;
  status = lcd.begin(LCD_COLS, LCD_ROWS);

  // Print a message to the LCD
  lcd.clear();
  lcd.setCursor (0, 0);
  lcd.print("hey, i work!!!"); // 1st row
  lcd.setCursor (0, 1);
  lcd.print("welcome"); // 2nd row
  lcd.setCursor (0, 2);
  lcd.print("it's a nice day!"); // 3rd row
  lcd.setCursor (0, 3);
  lcd.print("How are you?"); // 4th row
}

void loop()
{

}

So in the end, the frustration was self created with incorrect wiring and poor soldering. Those two things are fairly common when things don't work. Which is why showing an actual photo of your h/w is so important.

Yes, setCursor() is how you set the cursor for writing new characters, to a specific location.

The hd44780 LCD chipset is very dumb. It does not understand line endings and in fact it doesn't even know the actual geometry of the physical LCD. The LCD libraries are typically just sending the characters to the LCD and that is why sending and don't work as expected (the LCD treats them as custom characters) and the LCD doesn't do line wrapping. It is also why on a 20x4 display, by default when you scroll past the end of the first line, it doesn't wrap down to the 2nd line. (but it will when you enable hd44780 line wrapping)

The hd44780 library currently will do line wrapping, if enabled, and at some point hd44780 will be updated to support line endings and line scrolling so you will be able to use println() on the LCD. When that is added, if line wrapping, line endings, and line scrolling is enabled, it will work like a mini terminal.

But for now, only simple line wrapping is supported.

--- bill

The hd44780 library currently will do line wrapping, if enabled, and at some point hd44780 will be updated to support line endings and line scrolling so you will be able to use println() on the LCD.
When that is added, if line wrapping, line endings, and line scrolling is enabled, it will work like a mini terminal.

Wow - and eventually by then you have to call your fantastic library version 1.x!

BTW: Bill, did you read my last personal message?

rpt007: Wow - and eventually by then you have to call your fantastic library version 1.x!

Point taken. I need to push out a 1.0 release. The code is 99% there. The main thing lacking at this point is documentation and a few cleanup items relating to manual configuration for the I2Cexp i/o class, and AVR proprietary progmem usage for custom characters. Some of these cleanup items are tricky because they have long lasting implications and there can potentially be compatibility issues with other libraries. This is why the library is still in "alpha" state. I need to just make a few decisions and move on to get the 1.0 release out.

BTW: Bill, did you read my last personal message?

Yes, I did.

--- bill