How to interface 16x2 LCD display in serial mode using 2 wire system.

Table of Contents
Abstract
In this article, a comprehensive step-by-step guide to interface 16x2 I2C LCD display with Raspberry Pi Pico board using MicroPython. Raspberry Pi Pico has 4 different variants (Pico, Pico 2, Pico W, Pico 2W) supporting micro-python. This articles lays the foundation for more advanced embedded system and IoT projects.
Pre-Request
- OS : Windows / Linux / Mac / Chrome
- Thonny IDE.
- MicroPython firmware in Raspberry Pi Pico / Pico 2 / Pico W / Pico 2W.
- For step by step procedure click here .
Hardware Required
- Raspberry Pi Pico / Pico 2 / Pico W / Pico 2W.
- 16x2 I2C LCD.
- BreadBoard.
- Micro USB Cable.
- Connecting wires.
- 5V DC power supply (Optional)
| Components | Purchase Link |
|---|---|
| Raspberry Pi Pico | link |
| Raspberry Pi Pico 2 | link |
| Raspberry Pi Pico W | link |
| Raspberry Pi Pico 2W | link |
| 16x2 I2C LCD | link |
| BreadBoard | large : small |
| Connecting Wires | link |
| Micro USB Cable | link |
| 5V DC Adaptor | link |
Don't own a hardware
No worries,
Still you can learn using simulation.
check out simulation part .
Connection Table
Info
16x2 LCD can be connected in 4 wire and 8 wire mode. click here to know how to interface 16x2 LCD display in parallel mode using 4 wire or 8 wire system.
| 16x2 I2C LCD | GPIO | Remarks |
|---|---|---|
| GND (1) | GND | Ground |
| VCC (2) | +5 V | +5V of Board or External 5V DC Supply |
| SDA (3) | 8 | I2C0 series SDA pin |
| SCL (4) | 9 | I2C0 series SCL pin |
Note
- VCC (2) can be connected to external +5 V DC supply or to the VBUS pin number 40 of Raspberry Pi Pico Board.
- While using External 5 V supply for 16x2 LCD, make sure ground pin of External Supply and Pico board is connected.

fig-Connection Diagram
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
Code Explanation
Imports
timemodule for creating delay.pico_i2c_lcdmodule for interacting with 16x2 I2C lcd display hardware.
I2C address defnition.
0x27is the address of I2C LCD module.- Setting number of rows and columns of LCD display.
Instance of LCD display object.
- Creating the instance of i2c communication object.
- SDA pin to GPIO 8
- SCL pin to GPIO 9
- Depending upon your connection, change the GPIO pin numbers.
- Initialize the lcd Module
I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)- no of rows (2) and columns (16) for 16x2 LCD display
- if you are chosing 20x4 LCD module, change rows to 4 and column to 20
Displaying the content
lcd.clear()clear the screen and set the cursor position to (Row 1 and Column 1)lcd.putstr()used to send data to lcd module for display.lcd.move_to(<column>, <row>)lcd.move_to(0, 1)place the cursor to second line(row) and first character(column) position.lcd.backlight_off()turns the backlight led off.lcd.display_off()turns the display off.
Try It
- Alter the output content on the display by passing your data argument to the
putstrmethod.
Simulation
Not able to view the simulation
- Desktop or Laptop : Reload this page ( Ctrl+R )
- Mobile : Use Landscape Mode and reload the page
Extras
Components details
- Raspberry Pi Pico / Pico 2 : Pin Diagram
- Raspberry Pi Pico : Data Sheet
- Raspberry Pi Pico 2 : Data Sheet
- Raspberry Pi Pico W : Data Sheet
- Raspberry Pi Pico 2 W : Data Sheet
Modules / Libraries Used
- time
timemodule provides functions related to date & time, measuring time intervals and generating delays.- More Details
- lcd_api
- To interact with 16x2 LCD display.
- It is a third part library or user defined library.
- More Details
- pico_i2c_lcd
- To interact with 16x2 I2C module.
- It is a third part library or user defined library.
- More Details