# CircuitPython Hardware: ILI9341 TFT & FeatherWing

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/046/885/medium800/micropython_IMG_5604.jpg?1506987556)

https://youtu.be/9wsJzVeN_m8

Info: 

Small TFT displays are a great way to add graphics to your projects. &nbsp;These are like tiny little LCD monitors that you can drive with a simple SPI serial interface. &nbsp;You can even use these displays in CircuitPython and MicroPython&nbsp;using a module from Adafruit! &nbsp;This module allows you to do basic drawing like putting pixels and filling rectangles on TFT displays like the&nbsp;[TFT FeatherWing](https://www.adafruit.com/product/3315). &nbsp;You can start to explore a fun world of Python and graphical TFT displays!

This guide explores how to use ILI9341/ILI9340 TFT displays with CircuitPython and MicroPython. &nbsp;Note that right now drawing support for these displays is limited to basic pixel and rectangle drawing commands. &nbsp;You can [use another library to draw basic graphics](../../../../micropython-displays-drawing-shapes)&nbsp;or to [draw text](../../../../micropython-displays-drawing-text). &nbsp;In addition the touchscreens commonly found on these small TFT displays are not currently supported by the Python module. &nbsp;In the future a touchscreen module might be available, but for now these displays are only for viewing graphics.

# CircuitPython Hardware: ILI9341 TFT & FeatherWing

## Hardware

# Parts

You'll need the following parts to follow this guide:

 **CircuitPython board.** &nbsp;&nbsp;This guide focuses on the&nbsp;[ESP8266](https://www.adafruit.com/product/2821)&nbsp;and&nbsp;[Feather M0/SAMD21-based boards](https://www.adafruit.com/products/2772), but any CircuitPython board that supports SPI&nbsp;should work.

&nbsp;

If your board doesn't come with CircuitPython running on it already then check out your board's guide for how to load CircuitPython firmware. &nbsp;For example the&nbsp;[Feather M0 express guide](../../../../adafruit-feather-m0-express-designed-for-circuit-python-circuitpython/circuitpython)&nbsp;is a good reference.

![micropython_3403-00.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/886/medium640/micropython_3403-00.jpg?1506987715)

 **ILI9341/9340 TFT Display Breakout or&nbsp;FeatherWing.** &nbsp;&nbsp;If you're using a Feather the&nbsp;[TFT FeatherWing](https://www.adafruit.com/product/3315)&nbsp;is the perfect option that easily connects to the Feather. &nbsp;For other boards you'll need a ILI9341 or ILI9340 display breakout, like this large&nbsp;[2.8" TFT display breakout](https://www.adafruit.com/product/1770). &nbsp;ILI9340 displays like the&nbsp;[2.2" TFT breakout](https://www.adafruit.com/product/1480)&nbsp;or&nbsp;[2.4" TFT breakout](https://www.adafruit.com/products/2478)&nbsp;should work too. &nbsp;Make sure the display you're using has the ILI9341 or ILI9340 driver chip!

![micropython_3315-05.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/887/medium640/micropython_3315-05.jpg?1506987776)

**[Breadboard&nbsp;](https://www.adafruit.com/products/64)**and&nbsp;**[jumper wires](https://www.adafruit.com/products/153)**. &nbsp;If you aren't using a Feather and FeatherWing you'll need a breadboard and jumper wires to connect the components.

&nbsp;

**[Soldering tools](https://www.adafruit.com/products/136)**. &nbsp;You'll need to solder headers to the boards &nbsp;Check out the&nbsp;[guide to excellent soldering](../../../../adafruit-guide-excellent-soldering/tools)&nbsp;if you're new to soldering.

![micropython_136-01.jpg](https://cdn-learn.adafruit.com/assets/assets/000/046/888/medium640/micropython_136-01.jpg?1506987828)

Make&nbsp;sure to follow the board and&nbsp;[TFT FeatherWing](../../../../adafruit-2-4-tft-touch-screen-featherwing/overview)&nbsp;or&nbsp;[2.8" TFT display breakout guide](../../../../adafruit-2-dot-8-color-tft-touchscreen-breakout-v2/overview)&nbsp;to assemble and test the hardware before continuing!

# Wiring

If you're using a TFT FeatherWing and Feather just slide the wing onto the Feather board and you're all set! &nbsp;The FeatherWing will automatically be connected to the board using its SPI connection. &nbsp;Skip to the next&nbsp;page to learn about the software to control the display.

![](https://cdn-learn.adafruit.com/assets/assets/000/046/889/medium800/micropython_IMG_5600.jpg?1506987891)

If you're using a TFT display&nbsp;breakout you'll need to connect its power, ground, and SPI&nbsp;connections to the board. &nbsp;For example&nbsp;the wiring for a 2.8" TFT breakout&nbsp;to Feather HUZZAH ESP8266 might look like:

![](https://cdn-learn.adafruit.com/assets/assets/000/046/890/medium800/micropython-adafruit-28-tft_bb.png?1506987923)

[Fritzing Source](https://cdn-learn.adafruit.com/assets/assets/000/046/891/original/micropython-adafruit-28-tft.fzz?1506988004)
- **Board SCK / SPI clock&nbsp;** to&nbsp; **Display CLK / SPI clock**.
- **Board MO / MOSI&nbsp;/ data output** &nbsp;to&nbsp; **Display&nbsp;MOSI / data input**.
- **Board GPIO 0** &nbsp;(or any other GPIO pin) to&nbsp; **Display CS / chip select**.
- **Board GPIO 15** &nbsp;(or any other GPIO pin) to&nbsp; **Display DC / data/command**.
- **Board 3.3V power** &nbsp;to&nbsp; **Display VIN / voltage input**.
- **Board GND / ground** &nbsp;to&nbsp; **Display&nbsp;**** GND / ground**.
- **Display 3.3V output** &nbsp;to&nbsp; **IM3** ,&nbsp; **IM2** , and&nbsp; **IM1** &nbsp;(but&nbsp; **not** &nbsp; **IM0!** ) pins. &nbsp;This configures the breakout to use its SPI interface. &nbsp;See the breakout guide for&nbsp;[details on soldering closed these connections to make the SPI interface the default](../../../../adafruit-2-dot-8-color-tft-touchscreen-breakout-v2/spi-wiring#spi-mode-jumpers).

# CircuitPython Hardware: ILI9341 TFT & FeatherWing

## CircuitPython

# Adafruit CircuitPython Module Install

To use the TFT display&nbsp;with your&nbsp;[Adafruit CircuitPython](https://blog.adafruit.com/2017/01/09/welcome-to-the-adafruit-circuitpython-beta/)&nbsp;board you'll need to install the&nbsp;[Adafruit\_CircuitPython\_RGB\_Display](https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display)&nbsp;module on your board. &nbsp; **Remember this module is for Adafruit CircuitPython firmware and not MicroPython.org firmware!**

## Bundle Install

For express boards that have extra flash storage, like the Feather/Metro M0 express and Circuit Playground express, you can easily install the necessary libraries with&nbsp;[Adafruit's CircuitPython bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle). &nbsp;This is an all-in-one package that includes the necessary libraries to use the ILI9341&nbsp;display with CircuitPython. &nbsp;To install the bundle follow the steps in your board's guide, like&nbsp;[these steps for the Feather M0 express board](../../../../adafruit-feather-m0-express-designed-for-circuit-python-circuitpython/installing-libraries).

Remember for non-express boards like the Trinket M0, Gemma M0, and Feather/Metro M0 basic you'll need to manually install the necessary libraries from the bundle:

- **adafruit\_rgb\_display**
- **adafruit\_bus\_device**
- **adafruit\_register**

If your board supports USB mass storage, like the M0-based boards, then simply drag the files to the board's file system.&nbsp;**Note on boards without external SPI flash, like a Feather M0 or Trinket/Gemma M0, you might run into issues on Mac OSX with hidden files taking up too much space when drag and drop copying,&nbsp;[see this page for a workaround](../../../../micropython-for-samd21/usb-mass-storage#mac-osx-file-copy-issues).**

If your board doesn't support USB mass storage, like the ESP8266, then&nbsp;[use a tool like ampy to copy the file to the board](../../../../micropython-basics-load-files-and-run-code). You can use the latest version of ampy and its&nbsp;[new directory copy command](../../../../micropython-basics-load-files-and-run-code/file-operations#copy-directories-to-board)&nbsp;to easily move module directories to the board.

**Furthermore, CircuitPython for M0 boards after version 0.8.1 do not have the framebuf module built in to save flash space. So, please download and install the&nbsp;[pure Python implementation of framebuf](https://github.com/adafruit/micropython-adafruit-framebuf/releases)&nbsp;and copy it to lib folder of the board as well.**

Before continuing make sure your board's root filesystem has the&nbsp; **adafruit\_rgb\_display** ,&nbsp; **adafruit\_bus\_device** , and&nbsp; **adafruit\_register** &nbsp;folders/modules copied over.

![](https://cdn-learn.adafruit.com/assets/assets/000/046/892/medium800/micropython_Screen_Shot_2017-09-14_at_4.17.51_PM.png?1506988247)

# Usage

The following section will show how to control the LED backpack&nbsp;from the board's Python prompt / REPL. &nbsp;You'll walk through how to control the TFT&nbsp;display and learn how to use the CircuitPython module built for the display. &nbsp;As a reference be sure to&nbsp;[see the micropython-adafruit-rgb-display module documentation](http://micropython-rgb.readthedocs.io/en/latest/)&nbsp;too.

First&nbsp;[connect to the board's serial REPL&nbsp;](../../../../micropython-basics-how-to-load-micropython-on-a-board/serial-terminal)so you are at the CircuitPython&nbsp; **\>\>\>** &nbsp;prompt.

## SPI Initialization

On CircuitPython the SPI bus must be initialized before the display can be used by your code.&nbsp;&nbsp;Run the following code to import the necessary modules and initialize the SPI bus:

```
import board
import busio
import digitalio

spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)

# For the ESP8266
cs = digitalio.DigitalInOut(board.GPIO0)
dc = digitalio.DigitalInOut(board.GPIO15)

# For the Feather M0s
#cs = digitalio.DigitalInOut(board.D9)
#dc = digitalio.DigitalInOut(board.D10)
```

These lines create the SPI bus interface and two digital inputs/outputs for the chip select and data/command lines connected to the display. &nbsp;Notice that the pin numbers might be different depending on your board and how it's wired. &nbsp;Read the comments above and pick the correct&nbsp;two **cs** and **dc** lines to run for your setup.

## Display Initialization

Next to import the display library and initialize it run the following code:

```
from adafruit_rgb_display import ili9341, color565
display = ili9341.ILI9341(spi, cs=cs, dc=dc)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/046/893/medium800/micropython_IMG_20171002_171331253.jpg?1506990237)

When creating the display instance of the ILI9341 class you'll need to know which pins are connected to the display's&nbsp; **CS** ,&nbsp; **DC** , and optionally&nbsp; **RST** &nbsp;or&nbsp; **reset** &nbsp;line. &nbsp;For the TFT FeatherWing&nbsp;[see its guide for details on these pin connections](../../../../adafruit-2-4-tft-touch-screen-featherwing/pinouts#tft-control-pins).

The&nbsp; **CS** &nbsp;and&nbsp; **DC** &nbsp;parameters to the ILI9341 class initializer are required and should be a pin from the board module. In CircuitPython they are DigitalInOut objects instead of pins directly (like GPIO0) so that other types of GPIO can be used such as GPIO expanders.

There are a few optional keyword arguments you can specify too:

- **rst** &nbsp;- This is a GPIO pin connected to the RST or reset line on the display. &nbsp;The default for this is to not be specified and reset is not used.
- **width** &nbsp;- The width of the display in pixels, the default is 240.
- **height** &nbsp;- The height of the display in pixels, the default is 320.

# Drawing

Once the display is initialized you're ready to perform basic fill and pixel drawing. &nbsp;First to fill the display with a solid color use the&nbsp; **fill** &nbsp;function:

```
display.fill(color565(255, 0, 0))
```

![](https://cdn-learn.adafruit.com/assets/assets/000/046/894/medium800/micropython_IMG_20171002_171611702.jpg?1506990249)

You should see the display fill entirely with a solid red color after running the command above.

Notice how the **color565** &nbsp;function is called to get a color that's passed to the fill function. &nbsp;This&nbsp; **color565** &nbsp;function takes in the red, green, and blue color component values which should range from 0 (lowest intensity) to 255 (highest intensity). &nbsp;Try filling the display with different color values!

To clear the display back to black, fill it with a zero color value:

```
display.fill(0)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/046/895/medium800/micropython_IMG_20171002_171653777.jpg?1506990260)

You can draw individual pixels with the&nbsp; **pixel** &nbsp;function. &nbsp;For example to draw a white pixel at the origin position 0, 0:

```
display.pixel(0, 0, color565(255, 255, 255))
```

![](https://cdn-learn.adafruit.com/assets/assets/000/046/896/medium800/micropython_IMG_20171002_171848782.jpg?1506990271)

Or to draw a pixel at the opposite corner at position 239, 319:

```
display.pixel(239, 319, color565(255, 255, 255))
```

![](https://cdn-learn.adafruit.com/assets/assets/000/046/897/medium800/micropython_IMG_20171002_171918876.jpg?1506990282)

The&nbsp; **pixel** &nbsp;function takes the following parameters:

- **X positon of the pixel to draw.**
- **Y position of the pixel to draw.**
- **Color of the pixel.** &nbsp;&nbsp;Use the&nbsp; **ili9341.color565** &nbsp;function to generate this color value from red, green, blue component values.

In addition to pixel drawing there's a filled rectangle drawing command called&nbsp; **fill\_rectangle**. &nbsp;For example to draw a blue box in one quadrant of the screen run:

```
display.fill_rectangle(0, 0, 120, 170, color565(0, 0, 255))
```

![](https://cdn-learn.adafruit.com/assets/assets/000/046/898/medium800/micropython_IMG_20171002_172026360.jpg?1506990295)

The&nbsp; **fill\_rectangle** &nbsp;function takes the following parameters:

- **X position of the rectangle upper left corner.**
- **Y position of the rectangle upper left corner.**
- **Width of the rectangle in pixels.**
- **Height of the rectangle in pixels.**
- **Color of the rectangle.** &nbsp;&nbsp;Again use the ili9341.color565 function to generate this value.

That's all there is to drawing on the ILI9341 display with CircuitPython! &nbsp;Right now only basic fill, pixel, and filled rectangle drawing commands are supported. &nbsp;However since this is a pixel-based display you can also&nbsp;[draw text with the bitmap font library](../../../../micropython-displays-drawing-text). &nbsp;There's even a [basic graphics library to draw lines and other shapes](../../../../micropython-displays-drawing-shapes)!

# CircuitPython Hardware: ILI9341 TFT & FeatherWing

## CircuitPython Displayio Quickstart

We'll start with the 2.4" TFT FeatherWing which has an ILI9341 display on it. If you would like more information on this display, be sure to check out our&nbsp;[Adafruit 2.4" TFT FeatherWing guide](https://learn.adafruit.com/adafruit-2-4-tft-touch-screen-featherwing).

# Parts

To use this display with displayio, you will only need two main parts. First, you will need the TFT FeatherWing itself.

### TFT FeatherWing - 2.4" 320x240 Touchscreen For All Feathers

[TFT FeatherWing - 2.4" 320x240 Touchscreen For All Feathers](https://www.adafruit.com/product/3315)
A Feather board without ambition is a Feather board without FeatherWings! Spice up your Feather project with a beautiful 2.4" touchscreen display shield with built in microSD card socket. This TFT display is 2.4" diagonal with a bright 4 white-LED backlight. You get&nbsp; 240x320...

In Stock
[Buy Now](https://www.adafruit.com/product/3315)
[Related Guides to the Product](https://learn.adafruit.com/products/3315/guides)
![View of a TFT FeatherWing - 2.4" 320x240 Touchscreen For All Feathers. A polished finger drawing a heart on the touch screen. ](https://cdn-shop.adafruit.com/product-videos/640x480/3315-09.jpg)

And second, you will need a Feather such as the Feather M0 Express or the Feather M4 Express. We recommend the Feather M4 Express because it's much faster and works better for driving a display.

### Adafruit Feather M4 Express - Featuring ATSAMD51

[Adafruit Feather M4 Express - Featuring ATSAMD51](https://www.adafruit.com/product/3857)
It's what you've been waiting for, the Feather M4 Express featuring ATSAMD51. This Feather is fast like a swift, smart like an owl, strong like a ox-bird (it's half ox, half bird, OK?) This feather is powered by our new favorite chip, the **ATSAMD51J19** -&nbsp; with...

In Stock
[Buy Now](https://www.adafruit.com/product/3857)
[Related Guides to the Product](https://learn.adafruit.com/products/3857/guides)
![Angled shot of a Adafruit Feather M4 Express. ](https://cdn-shop.adafruit.com/640x480/3857-10.jpg)

For this guide, we'll assume you have a Feather M4 Express. The steps should be about the same for the Feather M0 Express. To start, if you haven't already done so, follow the assembly instructions for the Feather M4 Express in our&nbsp;[Feather M4 Express guide](https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51/assembly). We'll start by looking at the back of the 2.4" TFT FeatherWing.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/075/015/medium800/circuitpython_2.4-reverse.png?1556331491)

After that, it's just a matter of inserting the Feather M4 Express into the back of the TFT FeatherWing.

![](https://cdn-learn.adafruit.com/assets/assets/000/075/016/medium800/circuitpython_2.4-assembled.png?1556331529)

# Required CircuitPython Libraries

To use this display with `displayio`, there is only one required library.

[Adafruit_CircuitPython_ILI9341](https://github.com/adafruit/Adafruit_CircuitPython_ILI9341/releases)
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).&nbsp; Our introduction guide has&nbsp;[a great page on how to install the library bundle](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries)&nbsp;for both express and non-express boards.

Remember for non-express boards, you'll need to manually install the necessary libraries from the bundle:

- **adafruit\_ili9341**

Before continuing make sure your board's lib folder or root filesystem has the&nbsp; **adafruit\_ili9341** &nbsp;file copied over.

## Code Example Additional Libraries

For the Code Example, you will need an additional library. We decided to make use of a library so the code didn't get overly complicated.

[Adafruit_CircuitPython_Display_Text](https://github.com/adafruit/Adafruit_CircuitPython_Display_Text)
Go ahead and install this in the same manner as the driver library by copying the&nbsp; **adafruit\_display\_text** folder over to the **lib** folder on your CircuitPython device.

# CircuitPython Code Example
https://github.com/adafruit/Adafruit_CircuitPython_ILI9341/blob/main/examples/ili9341_simpletest.py

## Code Details

Let's take a look at the sections of code one by one.&nbsp;We start by importing the board so that we can initialize `SPI`, `displayio`, `terminalio` for the font, a `label`, and the `adafruit_ili9341`&nbsp;driver.

```auto
import board
import displayio
import fourwire
import terminalio
from adafruit_display_text import label
import adafruit_ili9341
```

Next we release any previously used displays. This is important because if the Feather is reset, the display pins are not automatically released and this makes them available for use again.

```
displayio.release_displays()
```

Next, we set the SPI object to the board's SPI with the easy shortcut function `board.SPI()`. By using this function, it finds the SPI module and initializes using the default SPI parameters. Next we set the Chip Select and Data/Command pins that will be used.

```
spi = board.SPI()
tft_cs = board.D9
tft_dc = board.D10
```

In the next line, we set the display bus to FourWire which makes use of the SPI bus. The reset parameter is actually not needed for the FeatherWing, but was added to make it compatible with the breakout displays. You can either leave it or remove it if you need access to an additional GPIO pin.

```auto
display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D6)
```

Finally, we initialize the driver with a width of 320 and a height of 240. If we stopped at this point and ran the code, we would have a terminal that we could type at and have the screen update.

```
display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/075/034/medium800/circuitpython_2.4-terminal.png?1556510158)

Next we create a background splash image. We do this by creating a group that we can add elements to and adding that group to the display. The display will automatically handle updating the group.

```auto
splash = displayio.Group()
display.root_group = splash
```

Next we create a Bitmap which is like a canvas that we can draw on. In this case we are creating the Bitmap to be the same size as the screen, but only have one color. The Bitmaps can currently handle up to 256 different colors. We create a Palette with one color and set that color to 0x00FF00 which happens to be green. Colors are Hexadecimal values in the format of RRGGBB. Even though the Bitmaps can only handle 256 colors at a time, you get to define what those 256 different colors are.

```
color_bitmap = displayio.Bitmap(320, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00 # Bright Green
```

With all those pieces in place, we create a TileGrid by passing the bitmap and palette and draw it at `(0, 0)` which represents the display's upper left.

```
bg_sprite = displayio.TileGrid(color_bitmap,
                               pixel_shader=color_palette,
                               x=0, y=0)
splash.append(bg_sprite)
```

This creates a solid green background which we will draw on top of.

![](https://cdn-learn.adafruit.com/assets/assets/000/078/928/medium800/circuitpython_2.4-green.png?1564765013)

Next we will create a smaller purple rectangle. The easiest way to do this is the create a new bitmap that is a little smaller than the full screen with a single color and place it in a specific location. In this case we will create a bitmap that is 20 pixels smaller on each side. The screen is 320x240, so we'll want to subtract 40 from each of those numbers.

We'll also want to place it at the position&nbsp;`(20, 20)` so that it ends up centered.

```
inner_bitmap = displayio.Bitmap(280, 200, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0xAA0088 # Purple
inner_sprite = displayio.TileGrid(inner_bitmap,
                                  pixel_shader=inner_palette,
                                  x=20, y=20)
splash.append(inner_sprite)
```

Since we are adding this after the first rectangle, it's automatically drawn on top. Here's what it looks like now.

![](https://cdn-learn.adafruit.com/assets/assets/000/078/929/medium800/circuitpython_2.4-green-purple.png?1564765446)

Next let's add a label that says "Hello World!" on top of that. We're going to use the built-in Terminal Font and scale it up by a factor of three. To scale the label only, we will make use of a subgroup, which we will then add to the main group.

Labels are centered vertically, so we'll place it at 120 for the Y coordinate, and around 57 pixels make it appear to be centered horizontally, but if you want to change the text, change this to whatever looks good to you. Let's go with some yellow text, so we'll pass it a value of `0xFFFF00`.

```python
text_group = displayio.Group(scale=3, x=57, y=120)
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
text_group.append(text_area) # Subgroup for text scaling
splash.append(text_group)
```

Finally, we place an infinite loop at the end so that the graphics screen remains in place and isn't replaced by a terminal.

```
while True:
    pass
```

![](https://cdn-learn.adafruit.com/assets/assets/000/078/930/medium800/circuitpython_2.4-hello-world.png?1564765810)

## Using Touch

We won't be covering how to use the touchscreen on the shield with CircuitPython in this guide, but the library required for enabling resistive touch is the&nbsp;[Adafruit\_CircuitPython\_STMPE610](https://github.com/adafruit/Adafruit_CircuitPython_STMPE610) library.

# Where to go from here

Be sure to check out this excellent&nbsp;[guide to CircuitPython Display Support Using displayio](https://learn.adafruit.com/circuitpython-display-support-using-displayio)

# CircuitPython Hardware: ILI9341 TFT & FeatherWing

## MicroPython

Warning: 

In addition to CircuitPython there's an older MicroPython version of the TFT&nbsp;library that you can use with some MicroPython boards. &nbsp;Before you get started it will help to be familiar with these guides for working with MicroPython:

- [MicroPython Basics: What is MicroPython?](../../../../micropython-basics-what-is-micropython)
- [MicroPython Basics: How to Load MicroPython on a Board](../../../../micropython-basics-how-to-load-micropython-on-a-board)
- [MicroPython Basics: Load Files & Run Code](../../../../micropython-basics-load-files-and-run-code)

See&nbsp;[all the MicroPython guides in the learning system](../../../../category/micropython)&nbsp;for more information.

# MicroPython Module Install

To use the TFT display&nbsp;with your MicroPython board you'll need to install the&nbsp;[micropython-adafruit-rgb-display MicroPython module](https://github.com/adafruit/micropython-adafruit-rgb-display)&nbsp;on your board. &nbsp; **Remember this module is for MicroPython.org firmware and not Adafruit CircuitPython!**

First make sure you are running the latest version of MicroPython for your board. &nbsp;If you're using the&nbsp; **ESP8266 MicroPython** &nbsp;port you&nbsp; **must** &nbsp;be running version&nbsp;**[1.8.5 or higher](http://micropython.org/download#esp8266)**&nbsp;as earlier versions do not support using .mpy modules as shown in this guide. &nbsp;

Next download the latest&nbsp; **ili9341.mpy** &nbsp;and&nbsp; **rgb.mpy** &nbsp;file&nbsp;from the&nbsp;[releases page](https://github.com/adafruit/micropython-adafruit-rgb-display/releases)&nbsp;of the&nbsp;[micropython-adafruit-rgb-display GitHub repository](https://github.com/adafruit/micropython-adafruit-rgb-display)&nbsp;and&nbsp;[use a tool like ampy to copy the files to the board](../../../../micropython-basics-load-files-and-run-code/overview).

# Usage

The following section will show how to control the ILI9341 display&nbsp;from the board's Python prompt / REPL. &nbsp; First&nbsp;[connect to the board's serial REPL&nbsp;](../../../../micropython-basics-how-to-load-micropython-on-a-board/serial-terminal)so you are at the MicroPython&nbsp; **\>\>\>** &nbsp;prompt.

## SPI Initialization

On MicroPython.org firmware which uses the machine API you can initialize SPI&nbsp;like&nbsp;[the MicroPython SPI guide mentions](../../../../micropython-hardware-spi-devices). &nbsp;For example on the ESP8266 with TFT FeatherWing you can run:

```
import machine
spi = machine.SPI(1, baudrate=32000000)
```

Notice how the baudrate is specifying the SPI bus clock speed at 32mhz. &nbsp;This means pixel data will be sent very quickly to the display--much quicker than a software SPI interface. &nbsp;These displays can actually run up to about 64mhz but the ESP8266 SPI hardware can't support that fast of a speed!

## Display Initialization

Next to import the display library and initialize it run the following code:

```
import ili9341
display = ili9341.ILI9341(spi, cs=machine.Pin(0), dc=machine.Pin(15))
```

&nbsp;When creating the display instance of the ILI9341 class you'll need to know which pins are connected to the display's&nbsp; **CS** ,&nbsp; **DC** , and optionally&nbsp; **RST** &nbsp;or&nbsp; **reset** &nbsp;line. &nbsp;For the TFT FeatherWing&nbsp;[see its guide for details on these pin connections](../../../../adafruit-2-4-tft-touch-screen-featherwing/pinouts#tft-control-pins).

The&nbsp; **CS** &nbsp;and&nbsp; **DC** &nbsp;parameters to the ILI9341 class initializer are required and should be a pin instance. &nbsp;There are a few optional keyword arguments you can specify too:

- **rst** &nbsp;- This is a GPIO pin connected to the RST or reset line on the display. &nbsp;The default for this is to not be specified and reset is not used.
- **width** &nbsp;- The width of the display in pixels, the default is 240.
- **height** &nbsp;- The height of the display in pixels, the default is 320.

## Drawing

After initializing SPI and the display you're ready to start drawing on it. &nbsp;The usage of the drawing library is exactly the same as with CircuitPython so [check out the CircuitPython drawing information](../../../../micropython-hardware-ili9341-tft-and-featherwing/circuitpython#drawing)--the same code will work on MicroPython too!


## Featured Products

### TFT FeatherWing - 2.4" 320x240 Touchscreen For All Feathers

[TFT FeatherWing - 2.4" 320x240 Touchscreen For All Feathers](https://www.adafruit.com/product/3315)
A Feather board without ambition is a Feather board without FeatherWings! Spice up your Feather project with a beautiful 2.4" touchscreen display shield with built in microSD card socket. This TFT display is 2.4" diagonal with a bright 4 white-LED backlight. You get&nbsp; 240x320...

In Stock
[Buy Now](https://www.adafruit.com/product/3315)
[Related Guides to the Product](https://learn.adafruit.com/products/3315/guides)
### 2.8" TFT LCD with Touchscreen Breakout Board w/MicroSD Socket

[2.8" TFT LCD with Touchscreen Breakout Board w/MicroSD Socket](https://www.adafruit.com/product/1770)
Add some jazz & pizazz to your project with a color touchscreen LCD. This TFT display is big (2.8" diagonal) bright (4 white-LED backlight) and colorful! 240x320 pixels with individual RGB pixel control, this has way more resolution than a black and white 128x64 display. As a bonus,...

In Stock
[Buy Now](https://www.adafruit.com/product/1770)
[Related Guides to the Product](https://learn.adafruit.com/products/1770/guides)
### Adafruit 2.4" TFT LCD with Touchscreen Breakout w/MicroSD Socket

[Adafruit 2.4" TFT LCD with Touchscreen Breakout w/MicroSD Socket](https://www.adafruit.com/product/2478)
Add some jazz & pizzazz to your project with a color touchscreen LCD. This TFT display is 2.4" diagonal with a bright (4 white-LED) backlight and it's colorful! 240x320 pixels with individual RGB pixel control, this has way more resolution than a black and white 128x64...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2478)
[Related Guides to the Product](https://learn.adafruit.com/products/2478/guides)
### 2.2" 18-bit color TFT LCD display with microSD card breakout

[2.2" 18-bit color TFT LCD display with microSD card breakout](https://www.adafruit.com/product/1480)
This lovely little display breakout is the best way to add a small, colorful, and bright display to any project. Since the display uses 4-wire SPI to communicate and has its own pixel-addressable frame buffer, it can be used with every kind of microcontroller. Even a very small one with low...

In Stock
[Buy Now](https://www.adafruit.com/product/1480)
[Related Guides to the Product](https://learn.adafruit.com/products/1480/guides)
### Adafruit Feather M0 Express

[Adafruit Feather M0 Express](https://www.adafruit.com/product/3403)
At the Feather M0's heart is an ATSAMD21G18 ARM Cortex M0+ processor, clocked at 48 MHz and at 3.3V logic, the same one used in the new&nbsp;[Arduino Zero](https://www.adafruit.com/products/2843). This chip has a whopping 256K of FLASH (8x more than the Atmega328 or 32u4) and...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3403)
[Related Guides to the Product](https://learn.adafruit.com/products/3403/guides)
### Adafruit METRO M0 Express - designed for CircuitPython

[Adafruit METRO M0 Express - designed for CircuitPython](https://www.adafruit.com/product/3505)
Metro is our series of microcontroller boards for use with the Arduino IDE. This new **Metro M0 Express** board looks a whole lot like our&nbsp;[original Metro 328](https://www.adafruit.com/product/2488), but with a huge upgrade. Instead of the ATmega328, this Metro...

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

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
### Adafruit GEMMA M0 - Miniature wearable electronic platform

[Adafruit GEMMA M0 - Miniature wearable electronic platform](https://www.adafruit.com/product/3501)
The **Adafruit Gemma M0** is a super small microcontroller board, with just enough built-in to create many simple projects. It may look small and cute: round, about the size of a quarter, with friendly alligator-clip sew pads. But do not be fooled! The Gemma M0 is incredibly...

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

## Related Guides

- [Adafruit Feather M0 Adalogger](https://learn.adafruit.com/adafruit-feather-m0-adalogger.md)
- [Adafruit Feather M0 Bluefruit LE](https://learn.adafruit.com/adafruit-feather-m0-bluefruit-le.md)
- [Adafruit 2.4" TFT FeatherWing](https://learn.adafruit.com/adafruit-2-4-tft-touch-screen-featherwing.md)
- [Adafruit Feather M0 Express](https://learn.adafruit.com/adafruit-feather-m0-express-designed-for-circuit-python-circuitpython.md)
- [Adafruit Metro M0 Express](https://learn.adafruit.com/adafruit-metro-m0-express.md)
- [Adafruit Trinket M0](https://learn.adafruit.com/adafruit-trinket-m0-circuitpython-arduino.md)
- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [Stumble-Bot](https://learn.adafruit.com/stumble-bot-with-circuit-playground-and-crickit.md)
- [What is Web MIDI & BLE MIDI?](https://learn.adafruit.com/web-ble-midi.md)
- [Halloween Sentry-Bot with CRICKIT for CPX](https://learn.adafruit.com/halloween-sentry-bot.md)
- [Compost Friend!](https://learn.adafruit.com/compost-optimization-machine.md)
- [LED NeoPixel Corset with Circuit Playground Express and MakeCode](https://learn.adafruit.com/led-corset-with-circuit-playground-and-makecode.md)
- [Logan’s Run Hand Jewel LED](https://learn.adafruit.com/led-in-you-hand-logans-run-life-clock.md)
- [RGB LED Matrix Basics](https://learn.adafruit.com/32x16-32x32-rgb-led-matrix.md)
- [CircuitPython Hardware: PCA9685 PWM & Servo Driver](https://learn.adafruit.com/micropython-hardware-pca9685-pwm-and-servo-driver.md)
- [Custom Controllers for MakeCode Arcade](https://learn.adafruit.com/custom-controllers-for-makecode-arcade.md)
- [Introducing Adafruit Feather](https://learn.adafruit.com/adafruit-feather.md)
- [Music Box with Dancing Adabot](https://learn.adafruit.com/music-box-with-circuit-python.md)
- [Hidden Ink UV Message Reader](https://learn.adafruit.com/hidden-ink-uv-message-reader.md)
- [Using MPL3115A2 with CircuitPython](https://learn.adafruit.com/using-mpl3115a2-with-circuitpython.md)
- [CircuitPython with Jupyter Notebooks](https://learn.adafruit.com/circuitpython-with-jupyter-notebooks.md)
- [Automation with Crickit and Capsela](https://learn.adafruit.com/automation-with-crickit-and-capsela.md)
