# I2C/SPI LCD Backpack

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/118/700/medium800thumb/arduino_compatibles_292-04_1.jpg?1677078568)

Character LCDs are a fun and easy way to have your microcontroller project talk back to you. They are also common, and easy to get, available in tons of colors and sizes. [We've written tutorials on using character LCDs with an Arduino](http://learn.adafruit.com/character-lcds) (or similar microcontroller) but find that the number of pins necessary to control the LCD can be restrictive, especially with ambitious projects. We wanted to make a 'backpack' (add-on circuit) that would reduce the number of pins without a lot of expense.

![](https://cdn-learn.adafruit.com/assets/assets/000/122/968/medium800/adafruit_products_292-11.jpg?1690378204)

By using simple I2C and SPI input/output expanders we have reduced the number of pins, while still making it easy to interface with the LCD. Only 2 pins are needed for I2C, 3 for SPI. For Arduino and CircuitPython/Python users, we provide an easy-to-use library that is backwards compatible with projects using the '6 pin' wiring.

This backpack comes with a 2-pin and 3-pin terminal block as shown (you can snap it together to make a 5-pin terminal and then solder it to the backpack for easy wiring).

![](https://cdn-learn.adafruit.com/assets/assets/000/122/969/medium800/adafruit_products_292-09.jpg?1690378224)

This backpack will work with any 'standard' character LCD, from 8x1 to 20x4 sizes! As long as they have a 16-pin single-line connection header at the top. [We carry a few LCDs that work great](http://www.adafruit.com/category/63_96). We suggest using our blue white 20x4 or 16x2 LCDs. Note that it does not work with 16x2 OLED displays. You can try to connect our RGB 16x2 or 20x4 LCDs, but this backpack will not control the RGB backlight so you'll have to use the backpack only for the 14 digital IO pins (pins #1-14) and connect the backlight pins (#15-#18) directly to your microcontroller with 4 extra wires for color/PWM control as if they were just an RGB LED.

![](https://cdn-learn.adafruit.com/assets/assets/000/122/970/medium800/adafruit_products_292-13.jpg?1690378244)

 **NEW! As of February 8, 2023** - This backpack now comes with a big re-spin that makes lots of improvements:

- We've added a 3-5V boost circuit so you can use this backpack to control 5V LCDs even with 3V power and logic.
- The contrast potentiometer is a lot nicer and easier to twist using a small screwdriver
- Added [SparkFun qwiic](https://www.sparkfun.com/qwiic) compatible **[STEMMA QT](https://learn.adafruit.com/introducing-adafruit-stemma-qt)** connectors for the I2C bus **so you don't even need to solder the I2C and power lines.** Just wire up to your favorite micro using a [STEMMA QT adapter cable.](https://www.adafruit.com/?q=stemma%20qt%20cable) [QT Cable is not included, but we have a variety in the shop](https://www.adafruit.com/?q=stemma+qt+cable&sort=BestMatch).
- Functionality and size/shape are the same - mechanically and code-wise it is a drop-in replacement.
- We've also updated this PCB with [Adafruit Pinguin](https://github.com/adafruit/Adafruit_Pinguin) to make a lovely and legible silkscreen.

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/118/699/medium800/arduino_compatibles_lcds___displays_i2cwire_t.jpeg?1677080320)

# I2C/SPI LCD Backpack

## Pinouts

![](https://cdn-learn.adafruit.com/assets/assets/000/118/701/medium800/arduino_compatibles_double.jpg?1677078634)

The default I2C address is **0x20**.

## Power Pins

- **3-5V** (VIN) - You can power the I2C/SPI LCD Backpack with 3 to 5V DC. There is a 3-5V boost circuit onboard so you can use this backpack to control 5V LCDs even with 3V power and logic.
- **GND** - Common ground for data and power.

## I/O Pins

Located along the top of the board, above the board label on the silk, are the input and output pins. These pins are for attaching an LCD screen to the backpack and are numbered 1-16. **Pin 1 is located furthest to the left when looking at the front of the board (the side with the Adafruit logo on the board silk).**

Advanced users can repurpose these pins for general purpose I/O expansion. The MCP23008 has 8 I/O pins (7 are connected, backpack pins 4, 6, 11, 12, 13, 14 and 15) with optional pull-ups and the SPI 74HC595 has 7 connected outputs (backpack pins 4, 6, 11, 12, 13, 14 and 16).

## I2C Logic Pins

- **CLK** (SCL) - I2C clock pin, connect to your microcontroller I2C clock line. This pin is level shifted so you can use 3-5V logic, and there's a **10K pullup** on this pin.
- **DAT** (SDA) - I2C data pin, connect to your microcontroller I2C data line. This pin is level shifted so you can use 3-5V logic, and there's a **10K pullup** on this pin.
- **[STEMMA QT](https://learn.adafruit.com/introducing-adafruit-stemma-qt) -** These connectors allow you to connectors to dev boards with&nbsp; **STEMMA QT** connectors or to other things with [various associated accessories](https://www.adafruit.com/?q=JST%20SH%204).

## SPI Enable Jumper

- **SPI Enable** - The SPI Enable Jumper is located on the back of the board, between the lower STEMMA QT connector and the terminal block pins. You can solder this jumper **closed** to control the backpack over SPI.

## SPI Pins

The I2C/SPI LCD Backpack can be controlled over SPI after soldering the **SPI Enable** jumper closed.

- **CLK** (SCK) - SPI clock input pin
- **DAT** (MOSI) -&nbsp;This is the SPI MOSI ( **M** icrocontroller **O** ut / **S** erial **I** n) pin. It is used to send data from the microcontroller to the backpack.&nbsp;
- **LAT** - This is the latch input, which transfers the received data to the output lines on the shift register for the LCD.

## Address Jumpers

On the back of the board are **three address jumpers** , labeled **A0** , **A1** , and **A2,** between the Adafruit logo on the board silk and the lower STEMMA QT port. These jumpers allow you to chain up to 8 of these boards on the same pair of I2C clock and data pins. To do so, you solder the jumpers "closed" by connecting the two pads.

The default I2C address is **0x20**. The other address options can be calculated by adding the **A**** 0/A1/A2 **to the base of** 0x20**.

**A0** sets the lowest bit with a value of **1** , **A1** sets the next bit with a value of **2** and **A2** sets the next bit with a value of **4.** The final address is **0x20 + A2 + A1 + A0** which would be **0x27**.

 So for example if **A2** is soldered closed and **A0** is soldered closed, the address is **0x20 + 4 + 1 = 0x25**.

 If only **A0** is soldered closed, the address is **0x20 + 1 = 0x21**

 If only **A1** is soldered closed, the address is **0x20 + 2 = 0x22**

 If only **A2** is soldered closed, the address is **0x20 + 4 = 0x24**

The table below shows all possible addresses, and whether the pin(s) should be high (closed) or low (open).

![](https://cdn-learn.adafruit.com/assets/assets/000/118/704/medium800/arduino_compatibles_addresses.jpg?1677079381)

## 3-5V Jumper

- **3-5V** - The 3-5V jumper is located on the back of the board between the CLK and 3-5V labels on the silk. If you **cut** this jumper, it will disconnect the 5V boost circuit from VCC, causing the backpack to output 3V logic to a connected LCD.

# I2C/SPI LCD Backpack

## Which LCD to Use?

![](https://cdn-learn.adafruit.com/assets/assets/000/001/875/medium800/lcds___displays_variety_t.jpeg?1396777100)

This backpack will work with any 'standard'/'classic'&nbsp; **character** &nbsp;LCD. It does not work with&nbsp; **graphic** &nbsp;LCDs. Character LCDs come in sizes ranging from 8x1 (8 characters, one line) to 40x4 (40 characters, four lines). The backpack will also only fit LCDs that have a single line of pins at the top, not the ones that have a 2x10 or 2x8 connector on the side. Those are much rarer these days but just keep a look out for that!  
  
The backpack will work with RGB LCDs. Just be aware that you won't be able to control the backlight pin, you can do that separately from the LCD control with your microcontroller.

The backpack **won't** work with 40x4 LCDs because they have a second Enable pin.

## Wait - the backpack has 16 holes, but my LCD only has 14 pins!

As long as your LCD has a&nbsp;HD44780&nbsp;driver chip, you're OK.&nbsp;The extra two pins are for the backlight. Your LCD doesn't have a backlight.   
  
We'll show you which holes to ignore in the Assembly section of this guide.

# I2C/SPI LCD Backpack

## Assembly

Warning: 

Putting together the backpack onto an LCD is a quick process, and should take only a few minutes with a soldering iron.# Parts Check
Verify you have everything in the bag, there should be an assembled and tested PCB, a 2-pin and 3-pin 3.5mm terminal block. The backpack does not come with header or an LCD.  
## Terminal Blocks
The&nbsp;[terminal blocks](http://www.adafruit.com/partfinder/terminals "Link: http://www.adafruit.com/partfinder/terminals")&nbsp;allow you to easily attach and remove the LCD from your wiring, which we think is awfully handy. If you dont want the terminal blocks (they stick out a bit) you can always skip this step.

[The terminal blocks come in 2 and 3-pin pieces](http://www.adafruit.com/partfinder/terminals "Link: http://www.adafruit.com/partfinder/terminals")&nbsp;. Slide them together.

![](https://cdn-learn.adafruit.com/assets/assets/000/001/876/medium800/lcds___displays_terminalslide_t.jpeg?1396777104)

Place the blocks over the corner area of the backpack so that the holes stick out (unless for some reason you want them to face the other way)![](https://cdn-learn.adafruit.com/assets/assets/000/001/877/medium800/lcds___displays_terminalplace_t.jpeg?1396777110)

Solder them into place![](https://cdn-learn.adafruit.com/assets/assets/000/001/878/medium800/lcds___displays_terminalsoldered_t.jpeg?1396777116)

## Prepare LCD
Next we will attach the backpack to the LCD. First we must put header onto the LCD, if you bought the LCD from us, it will come with a stick of header. Otherwise, pick up some&nbsp;[standard 0.1" male header](http://www.adafruit.com/partfinder/header#male_header)

These photos shows a 10K potentiometer, you can ignore it

![](https://cdn-learn.adafruit.com/assets/assets/000/001/879/medium800/lcds___displays_parts_t.jpeg?1396777120)

If the header is too long, just cut/snap it short so that it is 16 pins

Next you'll need to solder the header to the LCD.You must do this, it is not OK to just try to 'press fit' the LCD!

![](https://cdn-learn.adafruit.com/assets/assets/000/001/880/medium800/lcds___displays_headersize_t.jpeg?1396777127)

The easiest way we know of doing this is sticking the header into a breadboard and then sitting the LCD on top while soldering. this keeps it steady.![](https://cdn-learn.adafruit.com/assets/assets/000/001/881/medium800/lcds___displays_lcdbb_t.jpeg?1396777131)

## Attach LCD
Now we will attach the backpack. We will show how to do this in a permanent fashion. If you think you would like to remove and replace the LCD at some time, you can use&nbsp;[a piece of 16-pin long 0.1" female header](http://www.adafruit.com/partfinder/header#female_header)&nbsp;as a socket but be aware it will stick out a lot.

There are two options, you can tuck the backpack behind the LCD

Danger: 

![](https://cdn-learn.adafruit.com/assets/assets/000/001/882/medium800/lcds___displays_option1_t.jpeg?1396777138)

Or solder it so it's to the side, this way it's thinner.![](https://cdn-learn.adafruit.com/assets/assets/000/001/883/medium800/lcds___displays_option2_t.jpeg?1396777141)

Solder the header to the backpack.![](https://cdn-learn.adafruit.com/assets/assets/000/001/884/medium800/lcds___displays_assembled_t.jpeg?1396777148)

Make sure that as you solder the first pin, the backpack PCB isn't leaning against the LCD, where the terminal blocks could short against some components. You can put some electrical tape or foam tape behind to avoid this if you think it could be an issue.![](https://cdn-learn.adafruit.com/assets/assets/000/001/885/medium800/lcds___displays_assembledside_t.jpeg?1396777153)

That's it!

## My LCD only has 14 pins. Which holes do I use?
The extra two pins are for the backlight. Your LCD doesn't have a backlight. Here's a picture of the backpack board layout, with pins 15 and 16 located. Just leave those empty. Cut the pin header down to 14 pins instead of 16, and&nbsp;attach your LCD to holes 1-14 in the backpack.  
![](https://cdn-learn.adafruit.com/assets/assets/000/002/871/medium800/lcds___displays_i2cspilcd_pins.png?1396788167)

If your LCD has 18 pins, you won't be able to use the extra backlight pins, just connect 1-16 and leave 17 and 18 disconnected

# I2C/SPI LCD Backpack

## Arduino I2C Use

The first option we'll show is how to use the I2C interface on the backpack. We'll be showing how to connect with an Arduino, for other microcontrollers please see our MCP23008 library code for the commands to send to the I2C I/O expander. I2C is nice because it only uses two pins, and you can put multiple I2C devices on the same two pins.

So for example, you could have up to 8 LCD backpacks+LCDs all on two pins! The bad news is that you have to use the 'hardware' I2C pins. You can't change those pins and you can't use them for reading analog data. If you absolutely need those two pins, use SPI (see the next section).

For this, we'll need to connect four wires: GND, 5V, CLK (clock) and DAT (data) via the STEMMA QT connection or the terminal block pins.

![](https://cdn-learn.adafruit.com/assets/assets/000/118/710/medium800/arduino_compatibles_metroStemma_bb.jpg?1677081029)

![](https://cdn-learn.adafruit.com/assets/assets/000/001/892/medium800/lcds___displays_i2cwire_t.jpeg?1396777195)

## Install Adafruit\_LiquidCrystal

To begin reading sensor data, you will need to download the Adafruit\_LiquidCrystal library from the Arduino library manager.

Open up the Arduino library manager:

![](https://cdn-learn.adafruit.com/assets/assets/000/084/210/medium800/arduino_compatibles_library_manager_menu.png?1573774474)

Search for the&nbsp; **Adafruit LiquidCrystal&nbsp;** library and install it

![](https://cdn-learn.adafruit.com/assets/assets/000/084/211/medium800/arduino_compatibles_liquidcrystal.png?1573774499)

We also have a great tutorial on Arduino library installation at:  
[http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use](http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use "Link: http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use")

## Load Demo

Restart the IDE and load up the **Adafruit\_LiquidCrystal-\>HelloWorld\_i2c** demo

![](https://cdn-learn.adafruit.com/assets/assets/000/029/934/medium800/lcds___displays_i2cdemo.png?1453416384)

Upload the sketch. You should see the backlight turn on when the Arduino resets. If you don't see any characters, adjust the **Contrast** trim potentiometer with a mini-screwdriver until you see the text clearly

The default **HelloWorld** sketch blinks the backlight as well as updating the text.

**If you see the backlight blinking that means your connection to the I2C port is OK but the contrast is too low or too high** , or the LCD data pins are not solidly connected.

Check the contrast first by gently twisting the mini trim potentiometer, if that doesn't help, recheck your soldering and resolder all 16 of the LCD pins!  
  
Once you're done, you can remove the blinking LED backlight code:

> lcd.setBacklight(HIGH);  
> delay(500);  
> lcd.setBacklight(LOW);  
> delay(500);

![](https://cdn-learn.adafruit.com/assets/assets/000/001/893/medium800/lcds___displays_i2cconnect_t.jpeg?1396777200)

## Changing the I2C Address

If you want to have more than one LCD backpack device each one needs to have a unique 'address'. You can set the address by jumpering the **A0** &nbsp; **A1** &nbsp;and&nbsp; **A2** &nbsp;solder jumpers.&nbsp; By default, no jumpers are soldered, giving an address of **0x20** (offset **0** ). If you want to have an address of&nbsp; **0x23** (0x20 + offset **3** ) you would solder&nbsp; **A0** &nbsp;(bit 0) and&nbsp; **A1** (bit 1) for an address offset of "011" = 3 in binary.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/118/882/medium800/adafruit_products_arduino_compatibles_addresses.jpg?1677247594)

Then, in the code change:

```auto
// Connect via i2c, default address #0 (A0-A2 not jumpered)
LiquidCrystal lcd(0);
```

to

```auto
// Connect via i2c, address #3 (A0&A1 jumpered)
LiquidCrystal lcd(3);
```

# I2C/SPI LCD Backpack

## Arduino SPI Use

Another option for connecting is to use **SPI** , which is a simpler protocol. The good news about SPI is that its very simple and you can use **any** 3 pins to connect. You can share the **data** and **clock** pins with another device as long as they remain outputs, the **latch** pin should only be used for the backpack. So if you wanted 3 LCDs, for example, they would all have the same **data** and **clock** pins, but the **latch** pin would be different, for 5 pins total

Danger: 

The first thing you will need to do is to enable SPI. To do this, solder the **SPI Enable** solder jumper by heating up the pads with a soldering iron and soldering a blob onto both pins:

![](https://cdn-learn.adafruit.com/assets/assets/000/001/894/medium800/lcds___displays_spiump.jpeg?1396777205)

This will switch the backpack over to SPI mode instead of I2C. If you want to go back to I2C, use wick or a solder sucker to remove the jumper

Next we will connect 5 wires,&nbsp; **5V** ,&nbsp; **GND** ,&nbsp; **DAT** ,&nbsp; **CLK** , and&nbsp; **LAT**.

- To match the example,&nbsp; **CLK** &nbsp;goes to to Digital 2
- **DAT** &nbsp;to Digital 3,
- **LAT** &nbsp;to Digital 4

Once we have the example sketch running you can of course change these to anything you'd like

- Connect&nbsp; **5V** &nbsp;and&nbsp; **GND** &nbsp;to the 5v and Ground Arduino power pins. If you are using a 3.3V Arduino, you still need to power the LCD with 5V power! You can use 3.3V logic just fine

![](https://cdn-learn.adafruit.com/assets/assets/000/001/895/medium800/lcds___displays_spiwire_t.jpeg?1396777212)

## Install Adafruit\_LiquidCrystal

To begin reading sensor data, you will need to [use the Adafruit\_LiquidCrystal library.](https://github.com/adafruit/LiquidCrystal). You can install the&nbsp; **Adafruit\_LiquidCrystal**** &nbsp;**library for Arduino using the Library Manager in the Arduino IDE.

![](https://cdn-learn.adafruit.com/assets/assets/000/118/756/medium800/adafruit_products_Arduino_Open_Library_Manager.png?1677185017)

Click the&nbsp; **Manage Libraries ...** &nbsp;menu item, search for&nbsp; **Adafruit LiquidCrystal** and select the **Adafruit LiquidCrystal** &nbsp;library:

![](https://cdn-learn.adafruit.com/assets/assets/000/118/757/medium800/adafruit_products_lcdLib.png?1677185134)

If asked about any dependencies, click "Install All".

![](https://cdn-learn.adafruit.com/assets/assets/000/118/758/medium800/adafruit_products_depends.png?1677185250)

## Load Demo

Restart the IDE and load up the **Adafruit\_LiquidCrystal-\>HelloWorld\_SPI** demo

![](https://cdn-learn.adafruit.com/assets/assets/000/029/935/medium800/lcds___displays_demospi.png?1453416523)

Upload the sketch. You should see the backlight turn on when the Arduino resets. If you don't see any characters, adjust the **Contrast** trim potentiometer with a mini-screwdriver until you see the text clearly

The default HelloWorld sketch blinks the backlight as well as updating the text.

**If you see the backlight blinking that means your connection to the SPI port is OK but the contrast is too low or too high** , or the LCD data pins are not solidly connected.

Check the contrast first by gently twisting the mini trim potentiometer, if that doesn't help, recheck your soldering and resolder all 16 of the LCD pins!

![](https://cdn-learn.adafruit.com/assets/assets/000/001/896/medium800/lcds___displays_spiconnect_t.jpeg?1396777218)

Once you're done, you can remove the blinking LED backlight code:

> lcd.setBacklight(HIGH);  
> delay(500);  
> lcd.setBacklight(LOW);  
> delay(500);

# I2C/SPI LCD Backpack

## Python & CircuitPython

It's easy to use the character LCD backpack with CircuitPython or Python and the&nbsp;[Adafruit CircuitPython CharLCD](https://github.com/adafruit/Adafruit_CircuitPython_CharLCD)&nbsp;module.&nbsp;Just like [wiring up a LCD in parallel and controlling it from CircuitPython](https://learn.adafruit.com/character-lcds/python-circuitpython), you can use the I2C/SPI backpack to also control a LCD from CircuitPython or Python.&nbsp; The same&nbsp;[Adafruit CircuitPython CharLCD](https://github.com/adafruit/Adafruit_CircuitPython_CharLCD)&nbsp;module allows you to easily write Python code that controls a character LCD (remember only the single color backlight displays are supported by the backpack!).

## CircuitPython Microcontroller Wiring

Here's an example of wiring a Feather RP2040 to the backpack with a STEMMA QT cable or via the terminal blocks:

Warning: 

- **Board 3V** to **backpack VIN**
- **Board GND** &nbsp;to&nbsp; **backpack GND**
- **Board SCL&nbsp;** to&nbsp; **backpack CLK**
- **Board SDA&nbsp;** to&nbsp; **backpack DAT**

If using the original version of the backpack:

- **Board VUSB** &nbsp;to&nbsp; **backpack 5V&nbsp;** (remember using the VUSB output on a Feather means it **must** be connected to a 5V USB power source like your computer or a battery pack!&nbsp; You can alternatively use the 3.3V output of the Feather but it might not be enough to power the LCD.)

![arduino_compatibles_feather_backpack.jpg](https://cdn-learn.adafruit.com/assets/assets/000/118/706/medium640/arduino_compatibles_feather_backpack.jpg?1677080759)

![arduino_compatibles_FeatherM0_CharLCD_backpack_I2C_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/118/707/medium640/arduino_compatibles_FeatherM0_CharLCD_backpack_I2C_bb.jpg?1677080773)

Or you can wire the LCD backpack to your board using the SPI interface.&nbsp; **Remember you must also solder closed the SPI Enable bridge on the backpack!&nbsp;&nbsp;** Here's an example of wiring a Feather M4 to the backpack with a hardware SPI connection:

- **Board 3V** &nbsp;to&nbsp; **backpack VIN**
- **Board GND** &nbsp;to&nbsp; **backpack GND.**
- **Board&nbsp;SCK&nbsp;** to&nbsp; **backpack CLK.**
- **Board MOSI&nbsp;** to&nbsp; **backpack DAT.**
- **Board D5&nbsp;** to&nbsp; **backpack LAT.**

If using the original version of the backpack:

- **Board VUSB** &nbsp;to&nbsp; **backpack VIN** (remember using the VUSB output on a Feather means it&nbsp; **must** &nbsp;be connected to a 5V USB power source like your computer or a battery pack!&nbsp; You can alternatively use the 3.3V output of the Feather but it might not be enough to power the LCD.)

![arduino_compatibles_FeatherM0_CharLCD_backpack_SPI_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/064/845/medium640/arduino_compatibles_FeatherM0_CharLCD_backpack_SPI_bb.jpg?1541013962)

![arduino_compatibles_spi_enable_lcd_backpack.jpeg](https://cdn-learn.adafruit.com/assets/assets/000/064/847/medium640/arduino_compatibles_spi_enable_lcd_backpack.jpeg?1541014156)

Warning: 

## Python Computer Wiring

Since there's _dozens_ of Linux computers/boards you can use we will show wiring for Raspberry Pi. For other platforms, [please visit the guide for CircuitPython on Linux to see whether your platform is supported](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).&nbsp;

Here's the Raspberry Pi wired to the backpack using I2C:

- **Pi 3V** to&nbsp; **backpack VIN**
- **Pi GND** &nbsp;to&nbsp; **backpack GND.**
- **Pi SCL&nbsp;** to&nbsp; **backpack CLK.**
- **Pi SDA&nbsp;** to&nbsp; **backpack DAT.**

![arduino_compatibles_piStemma_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/118/708/medium640/arduino_compatibles_piStemma_bb.jpg?1677080852)

![arduino_compatibles_raspi_CharLCD_backpack_i2c_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/118/709/medium640/arduino_compatibles_raspi_CharLCD_backpack_i2c_bb.jpg?1677080864)

Here's the Raspberry Pi wired to the backpack using SPI:

- **Pi 3V** to&nbsp; **backpack VIN**
- **Pi GND** &nbsp;to&nbsp; **backpack GND.**
- **Pi SCK&nbsp;** to&nbsp; **backpack CLK.**
- **Pi MOSI&nbsp;** to&nbsp; **backpack DAT.**
- **Pi GPIO5&nbsp;** to&nbsp; **backpack LAT.**

![arduino_compatibles_raspi_CharLCD_backpack_spi_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/064/849/medium640/arduino_compatibles_raspi_CharLCD_backpack_spi_bb.jpg?1541015006)

## CircuitPython Installation of CharLCD Library

You'll need to install the [Adafruit CircuitPython CharLCD](https://github.com/adafruit/Adafruit_CircuitPython_CharLCD) library on your CircuitPython board.

First make sure you are running the&nbsp;[latest version of Adafruit CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython)&nbsp;for your board.

Next you'll need to install the necessary libraries&nbsp;to use the hardware--carefully follow the steps to find and install these libraries from&nbsp;[Adafruit's CircuitPython library bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases).&nbsp; Our CircuitPython starter guide has [a great page on how to use the library bundle](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries).

You'll need to install the necessary libraries from the bundle:

- **adafruit\_character\_lcd**
- **adafruit\_mcp230xx** (used only for I2C)
- **adafruit\_74hc595** (used only for SPI)
- **adafruit\_bus\_device** (only needed on non-Express boards with **adafruit\_bus\_device** not built in)

Before continuing make sure your board's lib folder or root filesystem has the library **&nbsp;** files and folders **&nbsp;** copied over.

Next[&nbsp;connect to the board's serial REPL](https://learn.adafruit.com/welcome-to-circuitpython/the-repl) so you are at the CircuitPython&nbsp; **\>\>\>** &nbsp;prompt.

## Python Installation of CharLCD Library

You'll need to install the Adafruit\_Blinka library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. [Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux)!

Once that's done, from your command line run the following command:

- `pip3 install adafruit-circuitpython-charlcd`

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

## Python & CircuitPython Usage

To demonstrate the usage of the character LCD&nbsp;we'll initialize it and&nbsp;write text using Python code.

### I2C Initialization

For an I2C backpack run the following code to import necessary modules, initialize the I2C bus, and create an instance of the character LCD class:

```auto
import board
import busio
import adafruit_character_lcd.character_lcd_i2c as character_lcd
i2c = busio.I2C(board.SCL, board.SDA)
cols = 16
rows = 2
lcd = character_lcd.Character_LCD_I2C(i2c, cols, rows)
```

Also notice you need to specify the number of columns and rows for your character LCD.&nbsp; The **cols** and **rows** variables above are setting these values for a 16x2 character LCD.&nbsp; Make sure to set the right value for your LCD!

## SPI Initialization

For a SPI backpack as wired above run the following code instead (again be sure to set the right **cols** and **rows** for your display!):

```auto
import board
import busio
import digitalio
import adafruit_character_lcd.character_lcd_spi as character_lcd
spi = busio.SPI(board.SCK, MOSI=board.MOSI)
latch = digitalio.DigitalInOut(board.D5)
cols = 16
rows = 2
lcd = character_lcd.Character_LCD_SPI(spi, latch, cols, rows)
```

The only big difference with a SPI connection is that you must also import the **digitalio** module and pass in a **DigitalInOut** pin for the latch line.&nbsp; Notice board pin **D5** is used for this wiring--be sure to change the pin if your wiring is different.

## Backpack Usage

Now you're ready to start writing text and characters on the display!&nbsp; The usage of the LCD class is **exactly the same** as [shown in the parallel LCD wiring guide](https://learn.adafruit.com/character-lcds/python-circuitpython#python-and-circuitpython-usage-7-12).&nbsp; Be sure to [check out that guide](https://learn.adafruit.com/character-lcds/python-circuitpython#python-and-circuitpython-usage-7-12) for a complete discussion of LCD usage.

As a quick test though you can run the following code to use the `message` property to write text to the display:

```auto
lcd.message = "Hello\nCircuitPython!"
```

![](https://cdn-learn.adafruit.com/assets/assets/000/048/992/medium800/arduino_compatibles_IMG_20171208_121255336.jpg?1512764365)

[See the parallel LCD guide for more functions you can call to control the LCD!](https://learn.adafruit.com/character-lcds/python-circuitpython#python-and-circuitpython-usage-7-12)

That's all there is to using the I2C/SPI backpack with CircuitPython!

## Full Example Code

As&nbsp;a complete example of I2C usage, see the [charlcd\_I2C\_simpletest.py](https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/blob/master/examples/charlcd_I2C_simpletest.py) example in the character LCD library.&nbsp; Save this as **code.py** on your board and it will run a small demo of LCD functions.

https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/blob/main/examples/charlcd_i2c_mono_simpletest.py

And a complete example of SPI usage is in the [charlcd\_SPI\_simpletest.py](https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/blob/master/examples/charlcd_SPI_simpletest.py) example in the library.&nbsp; Save this as **code.py** on your board and it will run a small demo of LCD functions.

https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/blob/main/examples/charlcd_spi_mono_simpletest.py

# I2C/SPI LCD Backpack

## Python Docs

# I2C/SPI LCD Backpack

## Downloads

- [MCP23008 Datasheet](https://cdn-shop.adafruit.com/datasheets/MCP23008.pdf)
- [EagleCAD PCB Files on GitHub](http://github.com/adafruit/i2c-SPI-LCD-backpack)
- [Original Fritzing object available in the Adafruit Fritzing Library](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%20I2C%2BSPI%20LCD%20Backpack.fzpz)
- [STEMMA QT Fritzing object in the Adafruit Fritzing Library](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%20I2C%20SPI%20LCD%20STEMMA%20Backpack.fzpz)

## STEMMA QT Schematic and Fab Print
![](https://cdn-learn.adafruit.com/assets/assets/000/118/702/medium800/arduino_compatibles_schem.png?1677078546)

![](https://cdn-learn.adafruit.com/assets/assets/000/118/703/medium800/arduino_compatibles_fab.png?1677078481)

## Original Schematic and Fab Print
![](https://cdn-learn.adafruit.com/assets/assets/000/035/681/medium800/lcds___displays_schem.png?1473701923)

![](https://cdn-learn.adafruit.com/assets/assets/000/035/682/medium800/lcds___displays_fabprint.png?1473701946)


## Primary Products

### i2c / SPI character LCD backpack - STEMMA QT / Qwiic

[i2c / SPI character LCD backpack - STEMMA QT / Qwiic](https://www.adafruit.com/product/292)
Character LCDs are a fun and easy way to have your microcontroller project talk back to you. They are also common, and easy to get, available in tons of colors and sizes. [We've written tutorials on using character LCDs with an Arduino](http://learn.adafruit.com/character-lcds)...

In Stock
[Buy Now](https://www.adafruit.com/product/292)
[Related Guides to the Product](https://learn.adafruit.com/products/292/guides)

## Related Guides

- [No-Code Indoor Air Quality Monitor with Separate Display](https://learn.adafruit.com/no-code-indoor-air-quality-monitor-with-separate-display.md)
- [ Faz-Wrench - Five Nights at Freddy's](https://learn.adafruit.com/faz-wrench.md)
- [Adafruit Trinkey QT2040](https://learn.adafruit.com/adafruit-trinkey-qt2040.md)
- [CircuitPython Servo Tester](https://learn.adafruit.com/circuitpython-servo-tester.md)
- [Adafruit STEMMA Reflective Photo Interrupt Sensor](https://learn.adafruit.com/adafruit-stemma-reflective-photo-interrupt-sensor.md)
- [Candy Bucket GIF Player Eyes](https://learn.adafruit.com/candy-bucket-gif-eyes.md)
- [Mini LED Matrix Audio Visualizer](https://learn.adafruit.com/mini-led-matrix-audio-visualizer.md)
- [Larsio Paint Music](https://learn.adafruit.com/larsio-paint-music.md)
- [1D Chomper Tabletop Arcade Game](https://learn.adafruit.com/1d-chomper-tabletop-arcade-game.md)
- [Adafruit VCNL4200 Long Distance IR Proximity and Light Sensor](https://learn.adafruit.com/adafruit-vcnl4200-long-distance-ir-proximity-and-light-sensor.md)
- [Haunted Portrait](https://learn.adafruit.com/haunted-portrait.md)
- [Adafruit Motor Shield](https://learn.adafruit.com/adafruit-motor-shield.md)
- [Adafruit Audio BFF](https://learn.adafruit.com/adafruit-audio-bff.md)
- [Adafruit TMAG5273 3D Hall Effect Magnetometer Breakout](https://learn.adafruit.com/adafruit-tmag5273-3d-hall-effect-magnetometer-breakout.md)
- [AWS IoT and Adafruit WICED Feather](https://learn.adafruit.com/aws-iot-and-adafruit-wiced-feather.md)
