Go Down

Topic: which library for i2C LCD (Read 12555 times) previous topic - next topic



I'm a newbie with arduino and I have a LCD module with I2C interface (this one http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html)

I tried to make the hello word, but it doesn't work (I don't have a compilation error, just the LCD become dark and nothing is write on it)

do you know which library to use with this lcd module

I use a Ubuntu desktop

thank you




We need more information.
Are you using the library that they provide?
What address are you using?

One thing that concerns me is that the library has support for s/w backlight
control but the board layout and the photo are showing a jumper to control
the backlight.

A clear closeup photo of the backpack you are actually using would help.
One that is good enough to be able to identify the i2c chip and the components on the
There are multiple i2c chips out there and they work differently and need/use different libraries.

--- bill


i used this code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x20 for a 16 chars and 2 line display

void setup()

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

void loop()



the i2c chip is PCF8574T.
when i used the potentiometer in back of the module, the screen become more dark, but nothing is write on it
i used a lot of library but no one works


the i2c chip is PCF8574T.
when i used the potentiometer in back of the module, the screen become more dark, but nothing is write on it
i used a lot of library but no one works

You need to be very methodical. i.e. don't change/try so many things all at once.
My suggestion, install the library referenced on their page.
I looked at the code and the board layout and they match so that code looks like it should work.
(At least it appears to be putting the lcd data and control lines on the proper output pins on the i2c chip)

Make sure to remove any other i2c lcd libraries to ensure you know which lcd i2c library is really
being used.
Look carefully at the i2c part. Who makes that chip? and it is a PCF8574T or a PCF8574AT ?
Different chips use different i2c base addresses.
Perhaps it is the AT chip?
If so, the i2c address should be 0x3f instead of 0x27

--- bill


i dit it

in first i used a I2C scanner, and i found the address 0x3F

after i used this library and this sketch

Code: [Select]
** Example Arduino sketch for SainSmart I2C LCD2004 adapter for HD44780 LCD screens
** Readily found on eBay or http://www.sainsmart.com/
** The LCD2004 module appears to be identical to one marketed by YwRobot
** Address pins 0,1 & 2 are all permenantly tied high so the address is fixed at 0x27
** Written for and tested with Arduino 1.0
** This example uses F Malpartida's NewLiquidCrystal library. Obtain from:
** https://bitbucket.org/fmalpartida/new-liquidcrystal
** Edward Comer
** LICENSE: GNU General Public License, version 3 (GPL-3.0)
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR    0x3F // Define I2C Address where the PCF8574A is
#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

int n = 1;

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
  lcd.begin (20,4);
// Switch on the backlight
  lcd.home ();                   // go home

  lcd.print("SainSmart I2C test"); 
  lcd.setCursor ( 0, 1 );        // go to the next line
  lcd.print("F Malpartida library");
  lcd.setCursor ( 0, 2 );        // go to the next line
  lcd.print("Test By Edward Comer");
  lcd.setCursor ( 0, 3 );        // go to the next line
  lcd.print("Iteration No: ");

void loop()
  // Backlight on/off every 3 seconds
  lcd.setCursor (14,3);        // go col 14 of line 3
  lcd.setBacklight(LOW);      // Backlight off
  lcd.setBacklight(HIGH);     // Backlight on

thanks to tried to help me



I used the exact sketch and library, but when I press Verify, I get the following error:

Arduino: 1.5.6-r2 (Windows 7), Board: "Arduino Due (Programming Port)"

D:\Arduino\libraries\LiquidCrystal\FastIO.cpp: In function 'void fio_shiftOut1(fio_register, fio_bit, uint8_t, boolean)':
D:\Arduino\libraries\LiquidCrystal\FastIO.cpp:214: error: '_BV' was not declared in this scope

Where am I going wrong ?


fm's currently released library does not work on Due.
--- bill


I have ARDUINO DUE R3 orig. + LCD 20x4 + I2C adapter (2pcs). 2 weeks of work and experiments. Result = zero = no LCD function.
Please question: does anyone have this combination in working order?
If yes, please refer to the IDE version, library and test.ino.
Thank you, mpcz, 08.may.2017

Go Up