User Tools

Site Tools


I2C LCD Character Display

LCD character panels can communicate via serial or parallel protocols. A common serial protocol is I2C which requires just two lines for communication in addition to power and ground (four wires total).

I2C is pronounced “I-squared-C” or “I-two_C”. I2C is an abbreviation for “Inter-Integrated Circuit”, which is a protocol for serial communication between many devices using a shared set of signal lines. Wikipeda <²C> and SparkFun <> have informative web pages about the I2C protocol.

On this page (the one you are reading) we describe how to communicate with an 20×4 LCD display panel having an I2C backpack. The wiring and code on this page has been tested and works with two readily available versions of 20×4 LCD displays with I2C backpacks:

Backpack and LCD panel

The following image from shows the backpack (top) and 20×4 character LCD panel (below). The backpack should be soldered to the pins on the larger PCB that holds the LCD module.

Sainsmart backpack and 20x4 character LCD display

View of Backpack attached to the LCD panel

The following image from shows the backpack attached to the back side of the 20×4 character LCD panel. Four pins protruding from the right side of the panel are used to connect to your Arduino.

Sainsmart backpack and 20x4 character LCD display


The following table shows how the four pins extending from the side of the backpack are connected to an Arduino.

Backpack Arduino Comment
GND GND Use any of the ground sockets on the Arduino
VCC 5V VCC is the 5V power for logic on the display panel
SDA SDA or A4 Data line.
SCL SCL or A5 Clock line.

Note: The LCD panel must be tolerant of 5V logic for the connections in the preceding table. The SparkFUN SerLCD panel used 3.3V logic, and should be connected to an Arduino with a Qwiic (STEMMA QT) connector that restricts VCC to 3V.

Arduino UNO boards have SCL and SDA pins at the end of the row of digital I/O pins. The A4 (analog input) pin is also connected to SDA, and the A5 pin is connected to SCL.


Communication with the I2C backpack is facilitated by the Liquid Crystal I2C library. Follow the link, or download this local copy.

To use the Liquid Crystal I2C library you will first need to

  1. Download the library from here or from here.
  2. Use the Arduino IDE to install the library: SketchInclude LibraryAdd .ZIP Library

If the display library is installed correctly, you should see a new LiquidCrystal_I2C entry in the list of examples in the Arduino IDE: FileExamplesLiquidCrystal_I2C. After you connect the Arduino to the LCD panel, you should be able to run any of the demo sketches in the set of examples for the LiquiCrystal_I2C library.

Sample Sketch for Potentiometer Display

The LCD_potentiometer_display.ino provides of another sample of using the LCD character display. The sketch reads a potentiometer connected to A2 analog input channel, and it displays the raw reading and the voltage on the first two lines of the LCD panel.

Using the Backlight

The LCD panels have a backlight that may help the readability of the display in bright surroundings. Typically you run the LCD either with or without the backlight. You do not turn it on and off while your code is running.

To turn on the backlight, include a call to the backlight method after you have initialized your LCD panel. Usually this is done in the setup function or in a user-defined LCD_setup function that does other tasks.


The backlight can also be turned off by removing the jumper on the back of the display. Removing the jumper only has an effect if the lcd.backlight() method is called in your code, i.e. if you have given the command to turn the backlight on.

Adjusting the Contrast

The backpack has a potentiometer for adjusting the contrast of the display. There is a good chance that when you first connect your display to an Arduino, the contrast is not correct and you either see a blank display or two rows of solid-filled character cells. Use a small screwdriver to adjust the potentiometer to make the characters output by your Arduino program visible.

i2c_lcd_character_display.txt · Last modified: 2020/02/10 07:05 by gerry