Arduino MicroPython LCD 20x4
This tutorial will instruct you how to use a 20x4 LCD I2C display with an Arduino board using MicroPython. You will learn:
- How to connect a 20x4 LCD I2C display to an Arduino
- How to write MicroPython code to display text, integers, floating-point numbers, and custom characters on a 20x4 LCD I2C display

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (30 sensors/displays) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Buy Note: Alternatively, you can assemble the LCD I2C display using LCD 1602 Display and PCF8574 I2C Adapter Module.
Overview of LCD I2C 20x4
Pinout
The LCD 20x4 I2C connects using the I2C interface and has 4 pins.
- GND pin: Connect this to GND (0 volts).
- VCC pin: Connect this to VCC (5 volts) to power the LCD.
- SDA pin: Used for I2C data signal.
- SCL pin: Used for I2C clock signal.

LCD Coordinate
The LCD I2C 20x4 includes 20 columns and 4 rows. Both columns and rows begin at 0.

Wiring Diagram

This image is created using Fritzing. Click to enlarge image
| LCD I2C | Arduino Giga |
|---|---|
| VCC | Vin 5V |
| GND | GND |
| SDA | D9 |
| SCL | D8 |
Arduino MicroPython Code
The below MicroPython code displays string, integer and float number on LCD 20x4 display.
Detailed Instructions
Here’s instructions on how to run the above MicroPython code on Arduino with Thonny IDE:
- Make sure Thonny IDE is installed on your computer.
- Make sure MicroPython firmware is installed on your Arduino board.
- If you are new to Arduino with MicroPython, see the Getting Started with Arduino and MicroPython.
- Connect the LCD 20x4 display to the Arduino according to the provided diagram.
- Connect the Arduino board to your computer with a USB cable.
- Open Thonny IDE and go to Tools Options.
- Under the Interpreter tab, select MicroPython (generic) from the dropdown menu.
- Select the COM port corresponding to your Arduino board (e.g., COM33 on Windows or /dev/ttyACM0 on Linux).
- Navigate to the Tools Manage packages on the Thonny IDE.
- Search “DIYables-MicroPython-LCD-I2C”, then find the LCD I2C library created by DIYables.
- Click on DIYables-MicroPython-LCD-I2C, then click Install button to install LCD I2C library.

- Copy the above provided code and paste it to the Thonny IDE's editor.
- Save the script to your Arduino board by:
- Click the Save button, or use Ctrl+S keys.
- In the save dialog, you will see two sections: This computer and MicroPython device. Select MicroPython device
- Save the file as main.py
- Click the green Run button (or press F5) to run the script. The script will execute.
- Check out the result on the LCD 20x4 display.

Arduino - 20x4 LCD - Custom Character
It is similar to LCD 16x2, you can refer to the custom character section on Arduino MicroPython LCD I2C tutorial, and then adapt it for LCD 20x4 display