Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Connect an I2C LCD to an Arduino Uno

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide walks you through wiring a 16x2 or 20x4 LCD with an I2C backpack to an Arduino Uno, and getting it to display text using the LiquidCrystal I2C library. You only need four jumper wires (plus power) instead of the usual 10+ connections, and the software setup takes about five minutes after the wiring is done.

What You'll Need

  • Arduino Uno board
  • I2C LCD module (usually a 16x2 or 20x4 character LCD with a PCF8574 backpack soldered on)
  • Four male-to-female jumper wires (or male-to-male if using a breadboard)
  • USB cable to connect the Arduino to your computer
  • Arduino IDE installed on your computer (version 1.8.x or 2.x)

Step-by-Step

  1. Identify the pins on the I2C LCD. Most modules have four pins: VCC (power), GND (ground), SDA (data), and SCL (clock). Some also have a fifth pin labeled LED or BLK for backlight control – you can leave that unconnected or tie it to VCC if you want the backlight always on.
  2. Connect power and ground. Use a jumper wire to connect the LCD's VCC pin to the Arduino's 5V pin. Connect the LCD's GND pin to any Arduino GND pin (e.g., the one next to 5V).
  3. Connect the I2C data line (SDA). On the Arduino Uno, SDA is the analog pin A4. Connect a jumper from the LCD's SDA pin to Arduino A4.
  4. Connect the I2C clock line (SCL). On the Uno, SCL is the analog pin A5. Connect a jumper from the LCD's SCL pin to Arduino A5.
  5. Double-check your wiring. You should have four connections: 5V to VCC, GND to GND, A4 to SDA, A5 to SCL. A common mistake is swapping SDA and SCL – verify the labels on your module.
  6. Install the LiquidCrystal I2C library. Open the Arduino IDE, go to Sketch → Include Library → Manage Libraries…. In the Library Manager, type LiquidCrystal I2C in the search box. Find the library by Frank de Brabander (the most widely used one) and click Install. If you see multiple results, pick the one with that author name.
  7. Find your LCD's I2C address. Most modules default to 0x27, but some use 0x3F. To be sure, upload the I2C scanner sketch: go to File → Examples → Wire → i2c_scanner. Upload it, open the Serial Monitor (set to 9600 baud), and note the address printed (e.g., “I2C device found at address 0x27”).
  8. Write a test sketch. Create a new sketch and paste this code, replacing the address with the one you found:
    #include <Wire.h>
    #include <LiquidCrystal_I2C.h>
    
    LiquidCrystal_I2C lcd(0x27, 16, 2); // address, columns, rows
    
    void setup() {
      lcd.init();
      lcd.backlight();
      lcd.setCursor(0, 0);
      lcd.print("Hello, World!");
    }
    
    void loop() {
    }
        
    If your display is 20x4, change the numbers to 20, 4.
  9. Upload the sketch. Connect the Arduino to your computer, select the correct board and port under Tools → Board and Tools → Port, then click the upload button (right arrow).
  10. Check the display. After upload, the LCD should light up and show “Hello, World!”. If you see only the backlight but no text, adjust the contrast potentiometer on the back of the module (usually a small blue screw) with a tiny screwdriver until characters appear.

Common Mistakes

  • Wrong I2C address. Using 0x27 when your module is 0x3F (or vice versa) is the most frequent error. Always run the scanner.
  • Swapped SDA and SCL. Double-check the labels – they are not interchangeable.
  • Powering from 3.3V. The Uno's 3.3V pin may not provide enough current for the LCD backlight. Use 5V.
  • Contrast set too low or too high. If you see blocks or nothing, the potentiometer is likely misadjusted.
  • Wrong library. The older LiquidCrystal library (without I2C) won't work. You need the I2C version.
  • Not calling lcd.init(). Some older examples use lcd.begin() – that only works with the non-I2C library. Use init() for this library.

Tips

  • Use short jumper wires (under 20 cm) to minimize noise and signal degradation.
  • If your module has a jumper for the backlight (often labeled “LED” or “BL”), make sure it's in place – otherwise the backlight won't turn on even with lcd.backlight().
  • To display numbers, use lcd.print(variable) – it works with int, float, and strings.
  • Clear the screen with lcd.clear() before writing new content to avoid ghosting.
  • If you're using multiple I2C devices, each must have a unique address. Many LCD backpacks have solder pads to change the address.

Troubleshooting

No backlight at all. Check power connections: VCC to 5V, GND to GND. Verify the USB cable provides power (the Arduino's ON LED should be lit). If you have a multimeter, confirm 5V between VCC and GND on the LCD.

Backlight on but no text. Run the I2C scanner to confirm the address. If the scanner doesn't find any device, check your SDA/SCL wiring – they must go to A4 and A5 respectively. Also try a different GND pin. If the scanner finds the device but text still doesn't appear, adjust the contrast potentiometer slowly while the sketch is running.

Garbage characters or blocks. This usually means the contrast is off or the wiring is loose. Re-seat the jumper wires. If you see solid blocks in the first row, that's often a sign of a wrong address – the LCD is receiving data but not the correct commands.

Text appears but is faint. Increase contrast by turning the potentiometer clockwise (or counterclockwise, depending on the module) until it's sharp. Also ensure you're using 5V, not 3.3V.

Compilation errors like “LiquidCrystal_I2C.h: No such file or directory”. The library isn't installed. Go back to Library Manager and install the correct one. Restart the IDE after installing.

Works on breadboard but not in final project. Long wires or a weak power supply can cause I2C issues. Keep wires short and add a 100nF capacitor between VCC and GND near the LCD if you suspect power noise.

Frequently Asked Questions

Q: Can I use the same pins for multiple I2C devices?
A: Yes, I2C is a bus – you can connect multiple devices to the same SDA and SCL lines as long as each has a unique address.

Q: Why does my LCD show nothing even after adjusting the contrast?
A: The most likely causes are a wrong library, wrong address, or a defective module. Run the scanner, reinstall the library, and try a different LCD if possible.

Q: Do I need external pull-up resistors?
A: Most Arduino boards and I2C modules already have pull-up resistors on the SDA and SCL lines. If you're using a very long cable, you might add 4.7kΩ resistors from SDA to 5V and SCL to 5V, but it's rarely needed.

Q: Can I power the LCD from the Arduino's 3.3V pin?
A: Technically yes, but the backlight may be dim or not light at all because 3.3V can't supply enough current. Use 5V for reliable operation.

Q: How do I change the I2C address if there's a conflict?
A: Look for a set of solder pads on the backpack labeled A0, A1, A2. Soldering these changes the address. For example, on a PCF8574, the default address is 0x27 (all pads open). Solder A0 to change it to 0x26, etc. Then update the address in your sketch.

Q: Why does my text disappear after a few seconds?
A: If you're writing in loop() without clearing, you might be overwriting. But if it disappears completely, check your power supply – a fluctuating voltage can cause the LCD to reset. Add a decoupling capacitor and ensure your USB port provides stable power.