[Tutorial] How to use an unknow I2C LCD library

This was a question, but I have figured it out from some great people here, so here It a quick tutorial showing you how to do it.

===> 1, Go download the I2c LCD library: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
===>2, unzip: LiquidCrystal_V1.2.1.zip; delete or move the original LiquidCrystal and all other lcd library you got
===>3, run the helloWorld_i2c example. if it works, you are good to go, but most likely it won't work.

reason it won't work:
A, wire connection is incorrect. for my Uno , connections are (sda - A4) (scl - A5);
B, incorrect address; All I2C device have an address from 8-127 something; mine is 0x27;
C, incorrect pins layout, you need to remap your pin. mine is lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE)

===>4, find your device address using this sketch while opening your serial Monitor : Arduino Playground - I2cScanner

it should come up like this:

Scanning...
I2C device found at address 0x27  !
done

===>5, find the pin layout: download i2cLCDguesser; open it with notpad; it's just an arduino sketch. from your serial Monitor. you should get something like this:

- Guess constructor for i2c LCD backpack
----------------------------------------------------------------
NOTE/WARNING: Guessing the i2c constructor is not really a
good thing since it could damage the hardware. Use with caution!
Do not leave things with an incorrect guess for too long.
i.e. advance to the next guess as soon as possible
when the guess in incorrect.
If the guess is correct, the constructor will show up
on the LCD.
----------------------------------------------------------------

<Press <ENTER> or click [Send] to Continue>
Scanning i2c bus for devices..
i2c device found at address 0x27
Device found: PCF8574
<Press <ENTER> or click [Send] to start guessing>
Trying: lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE)
<Press <ENTER> or click [Send] to Continue>

===>6, open that helloWorld_i2c example,
change
LiquidCrystal_I2C lcd(0x38); // Set the LCD I2C address
to (your result)
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE)

===> Done!!! It will work!!!!

i2cLCDguesser.zip (4.3 KB)

You find address 0x27 and use 0x20 in the sketch ?

Which I2C LCD is it ?

Is is like this one : LCD Shield Kit w/ 16x2 Character Display - Only 2 pins used! [BLUE AND WHITE] : ID 772 : $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits
Adafruit has also a tutorial and library for it.

did you try replacing the address here:

LiquidCrystal_I2C lcd(0x20,16,2);

with your address like this:

LiquidCrystal_I2C lcd(0x27,16,2);

and don't forget to tell lcd where to print:

lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Hello, world!");

Peter_n:
You find address 0x27 and use 0x20 in the sketch ?

Which I2C LCD is it ?

Is is like this one : LCD Shield Kit w/ 16x2 Character Display - Only 2 pins used! [BLUE AND WHITE] : ID 772 : Adafruit Industries, Unique & fun DIY electronics and kits
Adafruit has also a tutorial and library for it.

The code is from the example. I have changed it to 27 in my upload.

the lcd I got is this (with this chip on it :PCF8574T)):
http://www.dx.com/p/funduino-iic-i2c-1602-lcd-adapter-board-w-2-5-lcd-screen-black-green-red-173588#.U-mYLeNdXN0

BulldogLowell:
did you try replacing the address here:

LiquidCrystal_I2C lcd(0x20,16,2);

with your address like this:

LiquidCrystal_I2C lcd(0x27,16,2);

and don't forget to tell lcd where to print:

lcd.backlight();

lcd.setCursor(0,0);
lcd.print("Hello, world!");

after uploading the code, the screen is showing solid rectangles on the first line, and nothing on the second line.
Do I have a defective lcd? but while the code is being upload, the lcd turns off for a few sec. I think it's working fine.

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

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

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

void loop()
{
  
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Hello, world!");  
}

you mean the LED backlight turns on and off? that means it is communicating, likely.

it is likely that you need to adjust the contrast on the LCD display to get the letters to display properly

try to run your sketch and adjust the contrast with the on-board potentiometer.

BulldogLowell:
you mean the LED backlight turns on and off? that means it is communicating, likely.

it is likely that you need to adjust the contrast on the LCD display to get the letters to display properly

try to run your sketch and adjust the contrast with the on-board potentiometer.

It's not the problem with the contrast. I am sure of it.

It's not the problem with the contrast. I am sure of it.

will this blink the backlight?

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

LiquidCrystal_I2C lcd(0x27,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.setCursor(0,0);
  lcd.print("Hello, world!"); 
}

void loop()
{
  lcd.noBacklight();
  delay(1000);
  lcd.backlight();
  delay(1000);
}

BulldogLowell:

It's not the problem with the contrast. I am sure of it.

will this blink the backlight?

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,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.setCursor(0,0);
  lcd.print("Hello, world!");
}

void loop()
{
  lcd.noBacklight();
  delay(1000);
  lcd.backlight();
  delay(1000);
}

it won't!!!

I have ran scanner again. Just made triple sure my lines are correctly connected.

Scanning...
I2C device found at address 0x27 !
done

Scanning...
I2C device found at address 0x27 !
done

Funny thing, I found this info from the product site. This guy spent days figuring this out. I have spent more than 3 hours , and getting nothing.

again. I have tried the library he mentioned, and it didn't work. Then I just re-installed it again with his code, and doesn't work either.

How to work with arduino.
posted by JackWP on 08/22/2013
4
Involvement:Expert (understands the inner workings) - Ownership:1 week to 1 month

Pros:
Affordable. Small foot print. Can be configured to work with arduino.
I2C address = 0x27
Use new LCD library at.
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

Use:
#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin,BACKLIGHT_PIN,POSITIVE);

Mine works fine this way. I will order more!

Cons:
Can't make work with the manual provided (none).
Took me hours/days to get it working, but with my details, you may have faster results. Look out for the libraries, ans there are many, that look the same, but do not act the same.

OtherThoughts:
Once you get it working, this is a fine, value, brick.

Bottomline:
If you get one working, then, buy more. Well worth it. I will

how is your wired?

BulldogLowell:
how is your wired?

lcd - uno
gnd-gnd
vcc - 5v
sda - A4
scl - A5

seriously if my wires are incorrect, scanner won't give me a reading.

right, just checking.

Where did you download the library?

Hi, I recenly had same problem. Now solved with help from this forum.

http://forum.arduino.cc/index.php?topic=258616.msg1830183#msg1830183

Paul

he has an I2C piggyback board

look at this library:

https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

I had the same issue with the same LCD display and used this library... and it worked.

The latest version (V1.2.1) of the F.Malpartida library is at

https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

It should be installed in the sketchbook libraries which should be at C:\Users\yourName\Documents\Arduino\libraries

Remove any libraries named Liquid Crystal from the core libraries which came with the IDE at C:\Program Files (x86)\Arduino\libraries

If the constructor that you have found works, all is good.

#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin,BACKLIGHT_PIN,POSITIVE);

If it doesn't, the easiest thing to do in order to find the correct constructor is run the I2CLCDGuesser sketch fund here

http://forum.arduino.cc//index.php?topic=157817.msg1235230#msg1235230

cattledog:
The latest version (V1.2.1) of the F.Malpartida library is at

https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

It should be installed in the sketchbook libraries which should be at C:\Users\yourName\Documents\Arduino\libraries

Remove any libraries named Liquid Crystal from the core libraries which came with the IDE at C:\Program Files (x86)\Arduino\libraries

If the constructor that you have found works, all is good.

#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin,BACKLIGHT_PIN,POSITIVE);

If it doesn't, the easiest thing to do in order to find the correct constructor is run the I2CLCDGuesser sketch fund here

[SOLVED] MJKDZ brand I2C Controller working with 1602 LCD - #12 by bperrybap - Displays - Arduino Forum

finally. thank you. after 4 hours. Some numbers shows up. using the constructor. Have no idea what a constructor is but surely it is great.

 - Guess constructor for i2c LCD backpack
----------------------------------------------------------------
NOTE/WARNING: Guessing the i2c constructor is not really a
good thing since it could damage the hardware. Use with caution!
Do not leave things with an incorrect guess for too long.
i.e. advance to the next guess as soon as possible
when the guess in incorrect.
If the guess is correct, the constructor will show up
on the LCD.
----------------------------------------------------------------

<Press <ENTER> or click [Send] to Continue>
Scanning i2c bus for devices..
i2c device found at address 0x27
Device found: PCF8574
<Press <ENTER> or click [Send] to start guessing>
Trying: lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE)
<Press <ENTER> or click [Send] to Continue>

Hi

I planning to buy I2C backpack connect to 16x2 LCD. However, the the arduino uno interfaced with V3 GPS/GPRS/GSM module already. Means its RX/TX is engaged right? Is that possible to have connection between the pins of I2C BACKPACK lcd to arudino? as I2C needs define pins as below:

define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

So that is impossible to connect the engaged Tx/Rx right?

Thanks reply.=)
JJ

Means its RX/TX is engaged right?

Generally, no. Specifically, who knows. Links - not vague descriptions of shields!

An I2C device uses the I2C pins. Those pin numbers refer to pins on the shield, not pins on the Arduino.