Go Down

Topic: [Tutorial] How to use an unknow I2C LCD library (Read 7765 times) previous topic - next topic

arduinomagbit

Aug 12, 2014, 06:08 am Last Edit: Aug 12, 2014, 08:53 am by arduinomagbit Reason: 1
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 : http://playground.arduino.cc/Main/I2cScanner

it should come up like this:
Code: [Select]
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:
Code: [Select]

- 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!!!!

Peter_n

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

Which I2C LCD is it ?

Is is like this one : https://www.adafruit.com/products/772
Adafruit has also a tutorial and library for it.

BulldogLowell

did you try replacing the address here:

Code: [Select]
LiquidCrystal_I2C lcd(0x20,16,2);

with your address like this:

Code: [Select]
LiquidCrystal_I2C lcd(0x27,16,2);

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


Code: [Select]
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Hello, world!");

arduinomagbit


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

Which I2C LCD is it ?

Is is like this one : https://www.adafruit.com/products/772
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

arduinomagbit


did you try replacing the address here:

Code: [Select]
LiquidCrystal_I2C lcd(0x20,16,2);

with your address like this:

Code: [Select]
LiquidCrystal_I2C lcd(0x27,16,2);

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


Code: [Select]
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.

Code: [Select]
#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!"); 
}

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.




arduinomagbit


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.

BulldogLowell

Quote

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


will this blink the backlight?

Code: [Select]
#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);
}


arduinomagbit


Quote

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


will this blink the backlight?

Code: [Select]
#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.

Quote
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

BulldogLowell


arduinomagbit


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.


BulldogLowell

right, just checking.

Where did you download the library?


PaulRB

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

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

Paul

BulldogLowell

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.

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.
Quote
#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

Go Up