Home / Tutorials / Arduino Tutorial / How to Use I2C LCD with Arduino
Arduino I2C LCD Backpack

How to Use I2C LCD with Arduino

The classic parallel LCD sometimes post a problem for projects that use a lot of Arduino pins. The least amount of pins you can use is six, excluding the power pins and the potentiometer contrast adjust (optional) pin. Thankfully, by using an I2C LCD "backpack", the pin use can be reduced to four!

I2C LCD Backpack

This is the I2C LCD "backpack" I was referring to:

Image result for lcd i2c backpack

At the center of the board is the PCF8547 controller by NXP. The row of pins is attached to the same row of pins on any HD44870-compatible LCD. The four pins on the side are the one you'll attach to the Arduino or any I2C-supported microcontroller.

This is how the backpack looks like attached to a LCD:

Image result for lcd i2c backpack

Now let's look at the backpack in detail:

Image result for lcd i2c backpack LED pin

  • A trimmer is already attached to the board which acts as the contrast adjust. No more bulky potentiometers!
  • The jumper enables/disables the backlight. Remove the jumper to disable the backlight.
  • Some backpacks come with PCF8574T while some come with PCF8574AT. Each of this chips have their own I2C address! PCF84574T uses 0x27 while PCF8457AT uses 0x3F. These addresses are used in the sketch so they're kinda important to know.
  • You can, in fact, change the I2C address via the I2C Address Set pads on the board.  A0, A1, A2 represent three bits that would be subtracted from the address. By default, each of these pads are connected to VDD or the positive supply. Soldering them connects them to GND. For example, if you were to solder pad A0, the address becomes 0x26 because 0x27 - (A2 + A1 - A0) = 0x27 - (001)2 = 0x26. If you were to solder A0 and A1 then the address becomes 0x24 because 0x27 - (A2 + A1 + A0) = 0x27 - (011)2 = 0x24.
  • Changing the I2C address is necessary if you have multiple LCDs with the same backpack.

Using the I2C LCD with Arduino

For using with an Arduino, we'll need the LiquidCrystal_I2C library. Here's an example sketch which is found in File -> Examples -> LiquidCrystal_I2C -> HelloWorld:


The command to write a text on the LCD is the same as the original one:

Noticed before this line, we have this:

It's a way to enable/disable the backlight through code which is not part of the original LiquidCrystal library.

Also, here's how to initialize the I2C LCD object:

The first parameter is the I2C address, the second is the number of columns and the last number is the number of rows. The library can be used with other LCD sizes as long as the controller is HD44870.

Custom characters is also supported. Here's another example sketch from the library (File -> Examples -> LiquidCrystal_I2C -> CustomChars:


Here's the LCD with the backpack in action:

So far I'm really liking this I2C LCD backpack as it reduces the number of wires I have to use. If you're also having problem with the pin count of a common parallel LCD, then you should try this one.


Check Also

Sensor attached to Arduino UNO

Using a Fingerprint Sensor

Fingerprint sensors are old technology but it wasn’t readily available to makers until it was …

Leave a Reply

Your email address will not be published. Required fields are marked *