I²C LCD 16×2 or 20×4 Module Usage Guide

Thank you for purchasing an I²C LCD module from us or just stopping by to find out how to use a generic I²C LCD module. This guide applies to the following I²C LCD module we carry or similar I²C LCD module you can find in the market.

The good thing about I²C LCD module is they only use 2 wires instead of the 6 or more wire required for parallel connection style LCD.

Circuit

I lied, to connect I²C LCD module, you actually need 4-wires: 5V (VCC), GND, SDA, and SCL, as you can see in the image below. If you have an Arduino or Genuino board, wire your LCD module to the following pins:

Board I2C / TWI pins
Uno, Ethernet A4 (SDA), A5 (SCL)
Mega2560 20 (SDA), 21 (SCL)
Leonardo 2 (SDA), 3 (SCL)
Due 20 (SDA), 21 (SCL)

More information on the Arduino and Genuino I²C interface.

Wiring

Library

The are several libraries you can use for using the I²C LCD module but the following is one we recommend because we tested it and it works.

Download the library, unzip and copy it to your Arduino > Library folder.

Alternatively, you can use the Arduino IDE’s library manager and search for “LiquidCrystal I2C”.

Note: If you have an older version of this library, it will only work with an older version of the Arduino IDE. Download the newest or update the library to work with the current version of the Arduino IDE.

Code

You can jump directly to the example code provided but keep in mind that the default code is for a 20×4 character display with I²C address at 0x27.

If you are using a 16×2 LCD module, change the following this line at the top:

LiquidCrystal_I2C lcd(0x27,20,4);

to

LiquidCrystal_I2C lcd(0x27,16,2);

Or use the code below:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd 
  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("CANADA ROBOTIX");
  lcd.setCursor(1,1);
  lcd.print("Hello, world!");
}

void loop()
{
}

If your LCD module happens to have a different I²C address or you selected a different I²C address using the A0, A1, A2 solder pad (Only available in some version. See below for address interpretation), remember to change the default address “0x27”.

I²C Address

Some I²C LCD module have an address selector solder pad. They are usually labelled with A0, A1, and A2. The following table show you how to interpret the selector. “1” = Not Connected, “0” = Connected.

A0 A1 A2 HEX Address
1 1 1 0x27
0 1 1 0x26
1 0 1 0x25
0 0 1 0x24
1 1 0 0x23
0 1 0 0x22
1 0 0 0x21
0 0 0 0x20

 

Leave a Reply

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