Can't get 20x4 i2c display working

Hi, I’m a newby and hope you can help me with the following.

I have a 20X4 display bought from ebay.
As I connect power i see 2 black bars (bars 1 and 3).
I conntact A4 and A5 for the SDA ans SCL. I have a arduino Duemilanova

At http://arduino-info.wikispaces.com/LCD-Blue-I2C if downloaded the code.

/* YourDuino.com Example Software Sketch
 20 character 4 line I2C Display
 Backpack Interface labelled "LCM1602 IIC  A0 A1 A2"
 terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <Wire.h>  // 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 <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/
//none
/*-----( 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(0x20, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address


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

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 and 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: CHAR, LINE) 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 ) */

When I try to upload the code I get ‘LiquidCrystal_I2C’ does not name a type
with thefollowing error:
sketch_jan31a:20: error: ‘LiquidCrystal_I2C’ does not name a type
sketch_jan31a.ino: In function ‘void setup()’:
sketch_jan31a:30: error: ‘lcd’ was not declared in this scope
sketch_jan31a.ino: In function ‘void loop()’:
sketch_jan31a:75: error: ‘lcd’ was not declared in this scope

I downloaded the different library’s from http://arduino-info.wikispaces.com/LCD-Blue-I2C or http://hmario.home.xs4all.nl/arduino/LiquidCrystal_I2C/ and different other sites and placed them in my library folder after i deleted the old library’s.

I’ve seen this topic before but it did not helpedfor me. Hope somebody have a tip for me.
The ebay seller who sold it as ‘IIC/I2C/TWI/SP??I Serial Interface2004 20X4 Character LCD Module Display Blue’
also placed in the description to do the following:

https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
but with a little change in the init lines:
LiquidCrystal_I2C lcd(0x20, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

Edit: What LCD do you have exactly? Does it look like the one shown in this link?

At http://arduino-info.wikispaces.com/LCD-Blue-I2C if downloaded the code.

Where did you install your library, and if you did install it correctly, did you close out and restart the Arduino software?

Hi,

First I deleted my folder "Display" from C:\Program Files (x86)\Arduino\libraries Then I unzipt the rar file into After placing the library files into my C:\Program Files (x86)\Arduino\libraries\Display

I closed the arduino program and than restarted it again.

http://yourduino.com/docs/LCD-20x4-New3-800.jpg comes really close to my display. My display have QC2004A on the backside (lift corner), and the I2C module don't have any serial/type marks on it.

I bought it from ebay. http://www.ebay.com/itm/IIC-I2C-TWI-SP-I-Serial-Interface2004-20X4-Character-LCD-Module-Display-Blue-/310575296583?pt=LH_DefaultDomain_0&hash=item484fbaf047 On the picture in the ad i see a LCM1602 IIC mark, but that is not on the real life unit

So it has no 4 pin backpack? Then it's not an I2C LCD, it's a regular 20x4 LCD that should work with the LiquidCrystal library.

Can you take a picture of your LCD module?

A while back I posted tips on Amazon.co.uk on how to get this device working.

HazardsMind: So it has no 4 pin backpack? Then it's not an I2C LCD, it's a regular 20x4 LCD that should work with the LiquidCrystal library.

Can you take a picture of your LCD module?

It has the backpack, but not the words on it. But it looks very similat.

DonMilne: A while back I posted tips on Amazon.co.uk on how to get this device working.

Unfortunately I don't have some programming skills so that will be quit a challange for me.

How is it wired? SCL -> A5, SDA -> A4.

Does your code compile without errors?

Tried both and also without any wires to the arduino.

All give the same errors =(

All give the same errors smiley-cry

what error, this?

When I try to upload the code I get ‘LiquidCrystal_I2C’ does not name a type
with thefollowing error:
sketch_jan31a:20: error: ‘LiquidCrystal_I2C’ does not name a type
sketch_jan31a.ino: In function ‘void setup()’:
sketch_jan31a:30: error: ‘lcd’ was not declared in this scope
sketch_jan31a.ino: In function ‘void loop()’:
sketch_jan31a:75: error: ‘lcd’ was not declared in this scope

if this is your error then it’s telling you “hei i cant read the library LiquidCrystal_I2C”
The LCM1602 IIC has a dark side because there are some chinese boards with the pins inverted and you cant use the original library for it.I atached 2 versions of the libraries for the LCM1602 IIC.
Test the chinese version and see the results.
Remember you can just have one at a time in your arduino Libraries folder.Test one and if not work remove it and test the next one.

I2C HD44780 Display.tar.gz (1.07 MB)

The following works.

/*
 * Displays text sent over the serial port (e.g. from the Serial Monitor) on
 * an attached LCD.
 * 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.backlight();
  Serial.begin(9600);
}

void loop()
{
lcd.print("test");
}

I get:
testtesttesttesttest
testtesttesttesttest
testtesttesttesttest
testtesttesttesttest

Zo there is a little progress.

Get errors while compling with a code like:
LiquidCrystal_I2C lcd(0x20, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

Tnx and i will try your library’s

If your getting test over and over again on the LCD itself, then it’s good. That’s what it should say. I’m sure it has some examples you can try, if not then try this.

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

uint8_t bell[8]  = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4};
uint8_t note[8]  = {0x2,0x3,0x2,0xe,0x1e,0xc,0x0};
uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
uint8_t heart[8] = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0};
uint8_t duck[8]  = {0x0,0xc,0x1d,0xf,0xf,0x6,0x0};
uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0};
uint8_t cross[8] = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0};
uint8_t retarrow[8] = {	0x1,0x1,0x5,0x9,0x1f,0x8,0x4};
  
LiquidCrystal_I2C lcd(0x20,16,2);  // set the LCD address to 0x20 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd 
  lcd.backlight();
  
  lcd.createChar(0, bell);
  lcd.createChar(1, note);
  lcd.createChar(2, clock);
  lcd.createChar(3, heart);
  lcd.createChar(4, duck);
  lcd.createChar(5, check);
  lcd.createChar(6, cross);
  lcd.createChar(7, retarrow);
  lcd.home();
  
  lcd.print("Hello world...");
  lcd.setCursor(0, 1);
  lcd.print(" i ");
  lcd.write(3);
  lcd.print(" arduinos!");
  delay(5000);
  displayKeyCodes(); 
}

// display all keycodes
void displayKeyCodes(void) {
  uint8_t i = 0;
  while (1) {
    lcd.clear();
    lcd.print("Codes 0x"); lcd.print(i, HEX);
    lcd.print("-0x"); lcd.print(i+16, HEX);
    lcd.setCursor(0, 1);
    for (int j=0; j<16; j++) {
      lcd.write(i+j);
    }
    i+=16;
    
    delay(4000);
  }
}

void loop()
{

}

Tnx,

With your code i get 2 bars of info with the strange caracters.
I also played with another sketch and now have 4 working bars.
Don’t know yet how to do the contrast and light yet, but there is some progress :slight_smile:

Tomorrow i will try to accomplish that.

Still don’t get it why the “LiquidCrystal_I2C lcd(0x20, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address” don’t work and also what if does, but i’m already happy that i get something on the display :slight_smile:

Don't know yet how to do the contrast and light yet,

DID YOU ADJUST THE CONTRAST POT YET ? (THE SQUARE BLUE THINGY ON THE BACKPACK ) ?

You're in the wrong topic. This is not a PROGRAMMING QUESTION. You need to REMOVE this post (with the REMOVE button in the right hand upper corner of the screen and REPOST it in the DISPLAYS topic . You can get help there.

First I deleted my folder "Display" from C:\Program Files (x86)\Arduino\libraries Then I unzipt the rar file into After placing the library files into my C:\Program Files (x86)\Arduino\libraries\Display

Hey guys, Is he supposed to be messing around with IDE installed libraries in the Program Files ? I thought all user installed libraries were supposed to be in c:\My Documents\Arduino\Libraries. NOT C:\Program Files (x86)\Arduino\libraries

It should go in MyDocuments/Arduino/libraries

raschemmel: You need to REMOVE this post (with the REMOVE button in the right hand upper corner of the screen and REPOST it in the DISPLAYS topic .

You haven't been following things. Only a Moderator can move posts in that fashion. You cannot remove posts that follow your own, and even if there are none, you cannot remove your primary post.

raschemmel: Is he supposed to be messing around with IDE installed libraries in the Program Files ? I thought all user installed libraries were supposed to be in c:\My Documents\Arduino\Libraries. NOT C:\Program Files (x86)\Arduino\libraries

bperrybap explained that to me. The "user" libraries can be in either place (mind you, I don't have "My Documents" here anyway :D) as suits needs. Putting them in My Documents allows you to use different IDE versions, while putting them in Program Files (/usr/share) allows them to be used by different users.

In general - but not exclusively - My Documents seems to be preferable.

Didn't know that about not being able to remove your primary post. So when I see a message from a moderator to repost in a more appropriate topic he just means post again but don't cover your tracks. ?

This is a simple case of the sketch wanting to use a different library than the one that is installed. The library the sketch needs is not installed properly.

I've seen some odd advice and suggestions in this thread so far.

My recommendations is to use fm's library and not waste any time on the other libraries. fm's library can work with all the PCF8574 based backpacks out there. The constructor must be properly filled in to tell the library how the PCF8574 pins is wired up to the HD44780 LCD module pins and backlight circuit.

This should only take a few minutes: Go get fm's library and install it. Pay attention to the installation instructions & details, making sure to remove any other i2c lcd libraries that may have been installed. Then fill in the constructor in your sketch to match your i2c backpack wiring. If you don't know how your board is wired, run the i2cLCDguesser sketch and it will give you the needed parameters.

You don't need to modify the guesser code, just run it as is.

--- bill

Tnx, i will try that. I first placed the topic here,because i thought there was a programming error. Sorry for that.

I will download fm's library (https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home) and than place it in my /user/ect.ect folder and will deleten liquidcrystal library's in my /programfiles/ect.ect. folder.

Tnx for all the help

The strange thing is that i get a working result with with another library and for example the following code.

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

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
  
  int relay1 = 2;
  int relay2 = 3;
  
  #define dataPin  A3
  #define clockPin A2
  SHT1x sht1x(dataPin, clockPin);
  
  
  
void setup()
{
  lcd.init();                      // initialize the lcd 
  lcd.init();
   lcd.backlight();
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.println("Starting up...");
   delay(1000);
}


void loop()
{
   float temp_c;
   float humidity;
   temp_c = sht1x.readTemperatureC();
   humidity = sht1x.readHumidity();
lcd.clear();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("T ");
  lcd.setCursor(2,0);

  lcd.print(temp_c);
   lcd.setCursor(6,0);
  lcd.print("C");
   lcd.setCursor(8,0);
   lcd.print("H");
      lcd.setCursor(10,0);
  lcd.print(humidity);
    delay(500);
}

The library i used called LiquidCrystal_I2C2004V1.

From bitbucket i downloaded version 2.1 but with no luck. It’s without light and see some cursors flashing by but not like “Hello Arduino” , what is in a test code.

Only strange thing now is, in my code with the "Starting up…"after my last period i get an strange karacter.

Like this:

But I can work with it :slight_smile: