Good idea and glad to help floresta.
You will need to be ABSOLUTELY sure you have moved or deleted any library that says I2C, LiquidCrystal, LiquidCrystal_I2C, etc, and put the FM library (download from https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/LiquidCrystal_V1.2.1.zip) in /Arduino/libraries. Change the name to LiquidCrystal.zip and start the Arduino IDE. Go to Sketch-Include Library-Add .ZIP Library and select your renamed LiquidCrystal.zip library.
The LCD I am using (LCM-S01602DTR/M, $8.38 Mouser) does not have a backlight but its cheap enough and apparently HD44780 compliant. That said the pin to function numbering is standard. The numbering ON THE LCD is NOT standard. It is 14,13,12,…3,2,1,16,15. I have another LCD that is a straight 1-16 so ALWAYS check the data sheet for the device in hand.
First we will setup the I2C device, a PCF8574N from Mouser ($2.06)
Arduino Uno R3 A4 → PCF8574N SDA(pin15)
Arduino Uno R3 A5 → PCF8574N SCL(pin4)
Place +5VDC on pin 16 of the PCF8574N and tie pins 1,2,3,8 to ground. Grab Nick Gammons I2C Scanner, found at http://playground.arduino.cc/Main/I2cScanner, and run it.
// Version 1
// This program (or code that looks like it)
// can be found in many places.
// For example on the Arduino.cc forum.
// The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
// Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26 2013
// V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
// by Arduino.cc user Krodal.
// Changes by louarnold removed.
// Scanning addresses changed from 0...127 to 1...119,
// according to the i2c scanner by Nick Gammon
// Version 5, March 28, 2013
// As version 4, but address scans now to 127.
// A sensor seems to use address 120.
// Version 6, 20 May 2015
// Added on board visual LED check for hung state after 'endTransmission'.
// By Dale Ward
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
// initialize digital pin 13 as an output.
byte error, address;
digitalWrite(13, HIGH); // turn the on board LED on
//delay(1000); // wait for a second
nDevices = 0;
for(address = 2; address < 127; address++ )
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
error = Wire.endTransmission();
digitalWrite(13, LOW); // turn the LED off
if (error == 0)
Serial.print("I2C device found at address 0x");
else if (error==4)
Serial.print("Unknow error at address 0x");
if (nDevices == 0)
Serial.println("No I2C devices found\n");
delay(5000); // wait 5 seconds for next scan
You should see a result exactly like this:
I2C device found at address 0x20 !
If you do not see the above place a 4.7k resistor on the PCF8574N pin15 to +5VDC. That should make it work. If it doesn’t work check to be sure Windows has not dropped the Com port and double check your wiring. You CAN NOT proceed with the LCD until you have a recognized I2C device out there.
Next we will add our 16x2 LCD. On all HD44780 compliant LCD’s connect pin 1 and pin 16 to ground. Connect pin 2 and pin 15 to +5VDC. The rest of the pins can be connected many different ways but this definitely works:
LCD En (pin6) to P2(pin6) on PCF8574N
LCD RW (pin5) to P1(pin5) on PCF8574N
LCD RS (pin4) to P0(pin4) on PCF8574N
LCD D4 (pin11) to P4(pin9) on PCF8574N
LCD D5 (pin12) to P5(pin10) on PCF8574N
LCD D6 (pin13) to P6(pin11) on PCF8574N
LCD D7 (pin14) to P7(pin12) on PCF8574N
using the following test program:
/* This is a simple I2C to LCD test program using the fm library, LiquidCrystal_V1.2.1.zip.
Proper removal of any existing I2C or LiquidCrystal libraries prior to installing this library is absolutely essential.
All code here is open to the public to use as they see fit but no guarantees are stated or implied.
Code modified by Dale Ward, 20 May 2015.
LiquidCrystal_I2C lcd(0x20,2,1,0,4,5,6,7,3,POSITIVE); // Set the LCD I2C address and pins
lcd.begin(16,2); // initialize the lcd
lcd.home (); // go home
lcd.print("Hello, ARDUINO ");
lcd.print ("Have Fun!");
lcd.setCursor ( 5, 1 ); // go to the next line
This, like many hardware/software examples is quite simple IN HINDSIGHT. I am a 62 year old newb that believes in helping when you can but believe me when I say it took me DAYS to get to this ‘simple’ and effective solution for using an Arduino Uno Rev3 with a PCF8574N to talk to a 16x2 LCD via I2c. The key is the proper library installation. Good luck!!!