Arduino Nano 33 IoT - TFT LCD Touch Display SPI
Discover how to use an SPI TFT display with the Arduino Nano 33 IoT and the DIYables_TFT_SPI library. The Nano 33 IoT runs a SAMD21 Cortex-M0+ at 48 MHz, includes Wi-Fi and Bluetooth Low Energy, and operates at 3.3V logic throughout. Because most SPI TFT modules also run at 3.3V, the two pair together without any level shifting.
Along the way, you will discover:
- How to wire a 3.3V SPI TFT display to the Nano 33 IoT.
- How to draw shapes and graphics primitives.
- How to display text strings and numeric values.
- How to draw bitmap images stored in program memory (PROGMEM).
- How to draw bitmap images loaded from an SD card.
- How to render text with a custom external font.
- How to read raw touch coordinates from an XPT2046 controller.
- How to draw on screen by dragging a finger.
- How to create interactive touch buttons.
- How to calibrate the touch screen.
- How to use a secondary or custom SPI bus for the display.
This tutorial covers both touch and non-touch SPI TFT LCD displays. It works with 1.3, 1.54, 2.2, 2.4, 2.8, 3.2, and 3.5 inch panels driven by ILI9341, ILI9488, or ST7789 controller chips.

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Introducing the SPI TFT Display
SPI TFT modules combine a color LCD panel with a dedicated driver IC. The library supports three common drivers:
- ILI9341 - 16-bit RGB565 color, up to 40 MHz SPI.
- ILI9488 - 18-bit RGB666 color over SPI, up to 24 MHz.
- ST7789 - 16-bit RGB565 color, up to 40 MHz SPI.
Recommendation: If you have not yet purchased a display, we recommend the ST7789 driver. It is widely available, runs at full 40 MHz SPI speed, and is the most straightforward choice for new projects.
The library wraps Adafruit GFX, so shapes, text, fonts, and bitmaps are all available immediately.
Note: The Nano 33 IoT uses 3.3V logic on all pins. Connect VCC to the board's 3.3V pin only. Do NOT use 5V - it can damage the board.
Pinout
Most SPI TFT LCD displays have the following pins:
Display pins:
| Pin | Function |
|---|---|
| VCC | Power supply |
| GND | Ground |
| CS | Chip Select — pulled low to select the display on the SPI bus |
| DC / RS | Data / Command select — high for pixel data, low for commands |
| RST | Hardware reset — optional; tie to 3.3V if unused |
| MOSI / SDI / SDA | SPI data in (MCU → display) |
| SCK / CLK | SPI clock |
| MISO / SDO | SPI data out (display → MCU) — optional for display-only use |
| LED / BL / BLK | Backlight power — connect to 3.3V or a PWM pin for dimming |
SD card pins (if your application needs to access the SD card):
| Pin | Function |
|---|---|
| SD_CS / TF_CS | SD card Chip Select |
| MOSI / SDI | MOSI — data from MCU to SD card |
| SCK / CLK | SCK — SPI clock |
| MISO / SDO | MISO — data from SD card to MCU |
For TFT displays that support touch, there are additional touch pins (if your application uses the touch function and the display supports it):
| Pin | Function |
|---|---|
| T_CS | Touch controller Chip Select |
| T_CLK | SCK — SPI clock |
| T_DIN | MOSI — data from MCU to touch controller |
| T_DO | MISO — data from touch controller to MCU |
| T_IRQ | Touch interrupt — optional; signals when the screen is being touched |
Note: Some non-touch display modules also expose T_CS, T_CLK, T_DIN, T_DO, and T_IRQ pins. These are non-functional on those boards — the touch controller IC is not populated. They appear because the PCB reuses the same layout as the touch-enabled version to reduce manufacturing variants.

Wiring Diagram
Note — SDO (MISO) is optional: The SDO (MISO) line only carries data from the display back to the board. None of the example code in this tutorial reads from the display, so this pin can be left unconnected. On modules where the touch controller shares the same SPI bus, a connected SDO line can interfere with communication, so leaving it unconnected is recommended.
Without Touch
Connect MOSI to D11, SCK to D13, MISO to D12 on the Nano 33 IoT. CS, DC, and RST can be any available GPIO — D10, D8, D9 are used in the examples.
Display:
| TFT Pin | Arduino Nano 33 IoT Pin | Description |
|---|---|---|
| VCC | 3.3V | Power supply (3.3V only) |
| GND | GND | Ground |
| CS | D10 | Chip Select |
| DC / RS | D8 | Data / Command select |
| RST | D9 | Reset (optional) |
| MOSI / SDI | D11 | Hardware SPI MOSI |
| SCK | D13 | Hardware SPI clock |
| MISO / SDO | D12 | Hardware SPI MISO (optional) |
| LED / BL | 3.3V | Backlight power |
SD card (if your application needs to access the SD card):
| SD Pin | Arduino Nano 33 IoT Pin | Description |
|---|---|---|
| SD_CS / TF_CS | any free GPIO | SD card Chip Select |
| MOSI / SDI | D11 | Shared with display MOSI (D11) |
| SCK / CLK | D13 | Shared with display SCK (D13) |
| MISO / SDO | D12 | Shared with display MISO (D12) |

This image is created using Fritzing. Click to enlarge image
If you do not use a breadboard, wire it like this:

This image is created using Fritzing. Click to enlarge image
With Touch
Connect the XPT2046 touch controller to the Nano 33 IoT SPI bus, sharing D11, D13, and D12 with the display.
Want a cleaner and safer setup? A Screw Terminal Expansion Board for Arduino Nano solves this. Plug the Arduino Nano 33 IoT into it and screw the wires in. The wiring stays the same. Only the wires now go to the screw terminals, as shown below.

This image is created using Fritzing. Click to enlarge image
Display:
| TFT Pin | Arduino Nano 33 IoT Pin | Description |
|---|---|---|
| VCC | 3.3V | Power supply (3.3V only) |
| GND | GND | Ground |
| CS | D10 | Chip Select |
| DC / RS | D8 | Data / Command select |
| RST | D9 | Reset (optional) |
| MOSI / SDI | D11 | Hardware SPI MOSI |
| SCK | D13 | Hardware SPI clock |
| MISO / SDO | D12 | Hardware SPI MISO (optional) |
| LED / BL | 3.3V | Backlight power |
Touch controller (if your application uses the touch function and the display supports it):
| Touch Pin | Arduino Nano 33 IoT Pin | Description |
|---|---|---|
| T_CS | any free GPIO | Touch Chip Select |
| T_IRQ | any free GPIO | Touch interrupt (optional) |
| T_DIN | D11 | Shared with display MOSI (D11) |
| T_CLK | D13 | Shared with display SCK (D13) |
| T_DO | D12 | Shared with display MISO (D12) |

This image is created using Fritzing. Click to enlarge image
The diagram below shows the same connections without a breadboard:

This image is created using Fritzing. Click to enlarge image
If your MCU has two or more hardware SPI interfaces, you can assign each peripheral (display, SD card, touch controller) to its own dedicated SPI bus. If your MCU has only one hardware SPI interface, all three peripherals share the same three data lines (MOSI, SCK, MISO) — on the Nano 33 IoT these are D11, D13, and D12. Each peripheral has its own CS pin, so only one is active at a time. The DIYables_TFT_SPI library manages both the display and the XPT2046 touch controller through a single API — no separate SPI library is needed for the touch side.
Loose wires are a common cause of strange bugs. Put the Arduino Nano 33 IoT on a Screw Terminal Expansion Board for Arduino Nano, then tighten each wire under a screw. The diagram below shows the same wiring with the screw terminal board.

This image is created using Fritzing. Click to enlarge image
Preparing the Library
- Connect the Arduino Nano 33 IoT to your computer using a Micro-B USB cable.
- In Arduino IDE, choose Arduino NANO 33 IoT as the board and select the correct port.
- Open the Libraries panel from the left sidebar.
- Search for "DIYables_TFT_SPI" and locate the one published by DIYables.
- Press Install to add it. Install all dependencies when prompted.
- Search for DIYables TFT SPI created by DIYables.io and click the Install button.
Note: If the board does not appear in the IDE, install the Arduino SAMD Boards core via the Boards Manager.
Core Sketch
The core structure that every DIYables_TFT_SPI sketch builds on:
Discover - Draw Shapes
The DrawShapes example uses Adafruit GFX primitives to draw circles, rectangles, triangles, and lines in various colors across the screen.
Give It a Try
- Wire the TFT module to the Nano 33 IoT as shown, using the 3.3V pin for VCC.
- Connect the Nano 33 IoT to your computer with a Micro-B USB cable.
- In Arduino IDE, select the board and port, paste the code, and press Upload.
- The screen fills with colored shapes that cycle continuously.
API Essentials
| Method | Role | Usage Example |
|---|---|---|
| begin() | Start the display controller. | TFT_display.begin(); |
| setRotation(r) | Set orientation 0-3. | TFT_display.setRotation(1); |
| fillScreen(color) | Clear screen to one color. | TFT_display.fillScreen(BLACK); |
| colorRGB(r,g,b) | Create a 16-bit color. | colorRGB(255,165,0) |
| drawCircle(x,y,r,color) | Circle outline. | TFT_display.drawCircle(80,80,40,RED); |
| fillRect(x,y,w,h,color) | Filled rectangle. | TFT_display.fillRect(0,0,100,60,BLUE); |
| drawLine(x0,y0,x1,y1,color) | Straight line. | TFT_display.drawLine(0,0,240,160,WHITE); |
Discover - Show Text and Number
The ShowTextAndNumber example prints text strings and numeric values using the built-in GFX text renderer.
Give It a Try
- Wire and upload as above.
- The screen shows lines of text in different colors and sizes.
API Essentials
| Method | Role | Usage Example |
|---|---|---|
| setTextColor(color) | Sets the text foreground color. | TFT_display.setTextColor(WHITE); |
| setTextSize(size) | Scales text. Size 1 = 6×8 px, size 2 = 12×16 px. | TFT_display.setTextSize(2); |
| setCursor(x, y) | Places the text cursor at pixel (x, y). | TFT_display.setCursor(10, 20); |
| print(value) | Prints a string or number at the cursor. | TFT_display.print("Nano 33!"); |
| println(value) | Prints and advances the cursor to the next line. | TFT_display.println(42); |
Discover - Draw Image
The DrawImage example brings a full-color RGB565 bitmap to life on the display. The image is stored in program flash inside bitmap.h as a PROGMEM const uint16_t array. Because the Nano 33 IoT's SAMD21 core reads PROGMEM data the same way as regular memory, the image is displayed without any special buffering in SRAM.
Copy bitmap.h into the sketch folder before you compile.
Give It a Try
- Drop bitmap.h into the same folder as the sketch.
- Wire the TFT module to the Nano 33 IoT. Remember to use the 3.3V pin for VCC.
- Connect the Nano 33 IoT to your computer with a Micro-B USB cable.
- In Arduino IDE, select the board and port, paste the code, and press Upload.
- The screen shows the bitmap image loaded from program flash.
API Essentials
| Method | Role | Usage Example |
|---|---|---|
| drawRGBBitmap(x,y,bitmap,w,h) | Draws an RGB565 PROGMEM bitmap with its top-left at (x, y). | TFT_display.drawRGBBitmap(0, 0, myImage, 240, 320); |
| fillScreen(color) | Clears the screen to a solid color before the bitmap is drawn. | TFT_display.fillScreen(BLACK); |
Discover - Draw Image SD Card
The DrawImageSDcard example discovers how to stream a large image file from an SD card directly to the display without loading the whole thing into RAM. A small chunk buffer handles the data transfer. On the Nano 33 IoT the SD module shares the 3.3V SPI bus with the display.
Wire the SD module to the same SPI pins (D11/D13/D12) as the display. Connect its CS to the pin defined as SD_CS_PIN in the sketch.
Give It a Try
- Wire the SD module to the Nano 33 IoT. Share the SPI bus (D11/D13/D12) with the display. Connect SD CS to your chosen pin.
- Copy a raw RGB565 binary image file to the root of the SD card. Dimensions must match the panel resolution.
- Connect the Nano 33 IoT to your computer with a Micro-B USB cable.
- In Arduino IDE, select board and port, paste the code, and press Upload.
- The display shows the image streamed from the SD card.
API Essentials
| Method | Role | Usage Example |
|---|---|---|
| startWrite() | Opens a raw SPI write transaction, asserting the display CS. | TFT_display.startWrite(); |
| setAddrWindow(x0,y0,x1,y1) | Defines the rectangular write region on the panel. | TFT_display.setAddrWindow(0, 0, 239, 319); |
| pushColors(buf, len) | Sends a buffer of RGB565 pixel values to the display. | TFT_display.pushColors(buf, 512); |
| endWrite() | Closes the SPI transaction and releases the display CS. | TFT_display.endWrite(); |
Discover - Use External Font
The UseExternalFont example discovers how much sharper text looks with a GFX-compatible custom font. The font is selected by calling setFont() with a pointer to the font descriptor. The 3.3V SAMD21 core handles font rendering identically to other Arduino platforms, so the same font headers work without modification.
Give It a Try
- Wire the TFT module to the Nano 33 IoT as shown in the wiring diagram. Use 3.3V for VCC.
- Connect the Nano 33 IoT to your computer with a Micro-B USB cable.
- In Arduino IDE, select board and port, paste the code, and press Upload.
- The display renders text in the custom font. Notice the improved clarity compared to the built-in font.
API Essentials
| Method | Role | Usage Example |
|---|---|---|
| setFont(&FontName) | Activates a custom GFX-compatible font. Pass NULL to restore the built-in 5×7 font. | TFT_display.setFont(&FreeSans12pt7b); |
| setCursor(x, y) | Positions the text cursor at the given pixel coordinate. | TFT_display.setCursor(10, 40); |
| setTextColor(color) | Sets the text foreground color. | TFT_display.setTextColor(WHITE); |
| print(text) | Prints a string at the cursor using the active font. | TFT_display.print("IoT Display"); |
Discover - Touch Get Point
The TouchGetPoint example lets you discover the raw output of the XPT2046 touch controller. Press various spots on the screen and observe the ADC X, Y, and pressure Z values printed to the Serial Monitor. Those values map the analog range of your particular panel — you will need them to calibrate the touch coordinates.
Wiring: share the 3.3V SPI bus (D11/D13/D12) between the XPT2046 and the display. T_CS→D7, T_IRQ→D6.
Give It a Try
- Wire the XPT2046 to the Nano 33 IoT. Share the SPI bus with the display. T_CS→D7, T_IRQ→D6.
- Connect the Nano 33 IoT to your computer with a Micro-B USB cable.
- In Arduino IDE, select board and port, paste the code, and press Upload.
- Open the Serial Monitor at 9600 baud. Touch the screen to see raw X, Y, and Z values printed.
API Essentials
| Method | Role | Usage Example |
|---|---|---|
| initTouchSPI(cs, irq) | Initializes the XPT2046 on the shared 3.3V SPI bus. Pass -1 for irq if the interrupt pin is not connected. | TFT_display.initTouchSPI(7, 6); |
| readTouchRaw(x, y, z) | Returns raw ADC values without any calibration. Returns true when the screen is pressed. | TFT_display.readTouchRaw(x, y, z); |
Discover - Touch Draw
The TouchDraw example discovers how responsive the XPT2046 touch controller feels by letting you paint directly on the display. Each touch point produces a small colored circle. Drag your finger to draw a continuous stroke across the glass.
Give It a Try
- Wire the XPT2046 to the Nano 33 IoT as described in the Touch Get Point section above.
- Connect the Nano 33 IoT to your computer with a Micro-B USB cable.
- In Arduino IDE, select board and port, paste the code, and press Upload.
- Drag a finger across the screen to paint on it.
API Essentials
| Method | Role | Usage Example |
|---|---|---|
| initTouchSPI(cs, irq) | Starts the XPT2046 on the shared SPI bus. | TFT_display.initTouchSPI(7, 6); |
| setTouchCalibration(minX,maxX,minY,maxY) | Maps raw ADC values to screen pixel coordinates. Obtain these four values from the TouchCalibration example. | TFT_display.setTouchCalibration(200, 3800, 300, 3700); |
| setTouchInvertX(invert) / setTouchInvertY(invert) | Flips the touch axis when X or Y is mirrored on your specific panel or batch. Call BEFORE setTouchCalibration(). | TFT_display.setTouchInvertY(true); |
| getTouch(x, y) | Returns calibrated pixel-space touch coordinates. Returns true while the screen is being touched. | if (TFT_display.getTouch(x, y)) { ... } |
| fillCircle(x, y, r, color) | Draws a dot at the touch position to build up the stroke. | TFT_display.fillCircle(x, y, 3, RED); |
Discover - Touch Calibration
The TouchCalibration example walks you through finding the raw ADC range specific to your XPT2046 panel. Touch each corner of the screen when prompted and read the minimum and maximum X and Y values from the Serial Monitor. Those four numbers are the calibration constants for all your other touch sketches.
Give It a Try
- Wire the XPT2046 to the Nano 33 IoT as described in the Touch Get Point section.
- Connect the Nano 33 IoT to your computer with a Micro-B USB cable.
- In Arduino IDE, select board and port, paste the code, and press Upload.
- Open the Serial Monitor at 9600 baud. Follow the prompts and touch each corner of the display.
- Copy the four printed values into setTouchCalibration() in all your other touch sketches.
API Essentials
| Method | Role | Usage Example |
|---|---|---|
| initTouchSPI(cs, irq) | Initializes the XPT2046 touch controller. | TFT_display.initTouchSPI(7, 6); |
| readTouchRaw(x, y, z) | Reads raw ADC values used to measure the calibration range. | TFT_display.readTouchRaw(x, y, z); |
| setTouchCalibration(minX,maxX,minY,maxY) | Stores the four calibration values so getTouch() maps raw readings to pixel coordinates. | TFT_display.setTouchCalibration(200, 3800, 300, 3700); |
| setTouchInvertX(invert) / setTouchInvertY(invert) | Flips the touch axis when X or Y is mirrored on your specific panel or batch. Call BEFORE running calibration so the stored values match your panel. | TFT_display.setTouchInvertY(true); |
Discover - Custom SPI
The CustomSPI example discovers how to route the display to an explicit SPI bus instance. On the Nano 33 IoT there is one hardware SPI bus on D11/D13/D12. Passing &SPI explicitly to the constructor gives you direct control over the SPI settings and makes the bus assignment visible in the code rather than implicit.
Give It a Try
- Wire the TFT display to the Nano 33 IoT as shown in the wiring diagram. Use 3.3V for VCC.
- Connect the Nano 33 IoT to your computer with a Micro-B USB cable.
- In Arduino IDE, select board and port, paste the code, and press Upload.
- The display initializes on the explicitly configured SPI bus and shows a color-bar test pattern.
API Essentials
| Method | Role | Usage Example |
|---|---|---|
| DIYables_ILI9341_SPI(w,h,cs,dc,rst,spi) | Constructor variant that accepts a pointer to any SPIClass instance. Omitting the last argument defaults to &SPI. | DIYables_ILI9341_SPI tft(240, 320, 10, 9, 8, &SPI); |
| begin() | Initializes the display on the configured SPI bus. | TFT_display.begin(); |
Troubleshoot
- Black screen -- Confirm VCC is 3.3V and that CS (D10), DC (D8), MOSI (D11), SCK (D13) are all connected.
- Display powers on but shows garbage -- Only one driver constructor should be active. Comment out the others.
- Image is shifted -- The width and height in the constructor must exactly match your physical panel.
- Touch not working -- Run the TouchCalibration example first, then paste the calibration values into your sketch.
- Board not recognized -- Make sure the Arduino SAMD Boards core is installed via the Boards Manager.
Platform Support
Built on Arduino standard APIs - runs on every Arduino-compatible platform (architectures=*).