When you connect a standard LCD to an Arduino, you’ll notice that it consumes a lot of I/O pins. In 4-bit mode, it typically uses six or more connections, leaving fewer pins for other sensors or modules.A simple solution is to use an I2C LCD display, which requires only two communication pins (SDA and SCL). These are different from the regular digital I/O pins and can be shared with multiple I2C devices on the same bus.
In this tutorial, we’ll learn how to interface an I2C LCD with an Arduino UNO and display text, numbers, and custom characters on it.
What Is an I2C LCD Module?An I2C LCD module allows you to display text and characters on a 16×2 LCD (16 columns × 2 rows) using the I2C communication protocol. I2C enables communication between a microcontroller and peripheral devices using only two wires — SDA (Serial Data) and SCL (Serial Clock).
Hardware OverviewAn I2C LCD consists of two main parts:
- HD44780-based Character LCD Display
- I2C LCD Adapter
I2C LCDs are designed to display ASCII characters. For example, a 16×2 display can show up to 32 characters across two lines.Each character is made of a 5×8 pixel grid, where each pixel can be turned ON or OFF by applying voltage. By controlling different pixel patterns, the display can show letters, numbers, and symbols.
2. I2C LCD AdapterThe adapter converts serial I2C data into parallel signals for the LCD. It include
- PCF8574 Chip: 8-bit I/O expander that converts serial I2C data to parallel output for the LCD.
- Trim-pot: Used to adjust the LCD contrast.
- Jumper: Controls the LCD backlight. Removing the jumper allows you to power the backlight externally or connect a potentiometer for brightness control.
The I2C LCD display comes with four pins, making connections simple and reducing wiring complexity:
- GND – Connect this pin to the ground (GND) of the Arduino or the external power source.
- VCC – Connect to the 5V output of the Arduino or a 5V external power supply.
- SDA (Serial Data) – This is the data line used for I2C communication.
- SCL (Serial Clock) – This is the clock line that synchronizes data transfer between devices.
Each I2C device on a bus must have a unique address. The PCF8574 chip sets this through three address pins (A0, A1, A2), each of which can be HIGH or LOW.This gives 8 possible addresses (2³ = 8), ranging from 0x20 to 0x27.
By default, all address pins are pulled HIGH, making the default address 0x27.Shorting any jumper (A0–A2) pulls the corresponding pin LOW, changing the address accordingly.
Interfacing I2C LCD with Arduino UNOConnecting an I2C LCD display to an Arduino UNO is quite simple.
- Connect the VCC pin of the I2C LCD module to the 5V pin on the Arduino.
- Connect the GND pin of the LCD to the Arduino’s GND.
- Then, connect the SDA (Serial Data Line) and SCL (Serial Clock Line) pins of the LCD to the SDA and SCL pins on the Arduino.
On the Arduino UNO, the SDA and SCL lines correspond to analog pins A4 and A5, respectively.
⚠️ When using the I2C interface, avoid using A4 and A5 for analog input functions, as they are dedicated to I2C communication.
Ensure that the A0, A1, and A2 address jumpers on the I2C module are not shorted.By default, when these pins are open, the I2C address is 0x27, which is the one used in the code.If all three pins are shorted, the address changes to 0x20.
Checkout this article to learn more: How to Create and Display Custom Characters on an I2C LCD
Comments