Skip to content

www.rolfje.com

Arduino and the QVGA 2.2″ TFT SPI screen

Posted on 2014-11-17 By rolfje 5 Comments on Arduino and the QVGA 2.2″ TFT SPI screen

QVGA SPI 2.2" 320x240 screenI went through all the struggles everybody else seems to be going through to get this screen connected to my Arduino Nano. I had the 5V to 3.3V voltage conversion problem, and the “only works with software interrupts” problem which makes the display run slow. The solutions are not complicated but not very wel documented. Until now.

Step 1: It’s a 3.3V screen
Before connecting the screen to your Arduino, it’s important to know that this screen uses 3.3V logic. That means that connecting your Arduino to it will likely ruin the screen. If you’re not using the CF cardreader on the screen then the communication is one-way to the screen. Converting your 5V outputs to 3.3V is really simple, all you need is a couple of cheap 1N4148 diodes and a few resistors (for alternatives, see below). Connect your screen as follows:

Simple Level Conversion

Please make sure you wire *all* connections in this schematic.

Step 2: Hidden pins in the code
The Adafruit ILI9340 library contains some examples on how to get the screen running. You’ll need the SPI and Adafruit_GFX libraries too, as shown in the header of the examples. Let’s look at a little code that alternates the screen between black and white:

/*
 * Example code to make the TFT alternate
 * between black and white using hardware SPI:
 */
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9340.h"

// TFT pin mappings for UNO/NANO
#define _sclk 13
#define _miso 12
#define _mosi 11
#define _cs   10
#define _dc    9
#define _rst   8

// Use hardware SPI
Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _rst);

void setup() {
 tft.begin();
 tft.fillScreen(ILI9340_GREEN);
}

void loop() {
 tft.fillScreen(ILI9340_BLACK);
 tft.fillScreen(ILI9340_WHITE);
}

Note that there is something funny going on here. The constructor for the Adafruit_ILI9340 object only has _cs, _dc, and _rst as parameter. Initially I thought “Great, only 3 connections to the display!”. Alas, this is not the case. You still need to wire the _sclk and _mosi port to the display. The _miso port can be left out, but you can’t use it for anything else on the Arduino side because the library seems to be accessing it.

If you have your connections correct and upload the example above to your Arduino, you should see your screen continuously alternate between black and white. You will be able to see the drawing of the screen, but it should not take more than 1 second to fill the whole screen. If it takes more than a second to fill the screen, you’re likely using the software SPI method. Check the code and the connections again.

This is how the data on the _mosi pin looks on a Tektronix 7623A oscilloscope when drawing graphics on the TFT screen. It’s not a perfect square because of the capacitance of the diodes, but the difference between high and low states is good enough and the slope is just fast enough so that the display sees all the bits that are sent to it:

MOSI data

Alternative 5V to 3.3V conversions:
Zener conversionIf you don’t have enough diodes, you can use zener diodes as shown on the right. I have not tested this on my screen but it should give you similar results, and saves you a few components.

A much nicer, two-way level conversion enables you to connect the _miso port to talk to the CF Card Reader. You can make this
with an N-Channel MOSFET. Check Andrew’s blog on how to use an N-channel FET to do the conversion:

level-converter-mosfet

If you need more speed or less components, you can also check out Maxim’s range of level conversion ICs.

Have fun!

Waterman fountain pen

Hardware, Software Tags:Arduino, hacking, programming

Post navigation

Previous Post: IARU Region 1 Bandplan up to 500MHz
Next Post: Import/export an Oracle Schema using JDBC

Comments (5) on “Arduino and the QVGA 2.2″ TFT SPI screen”

  1. Manu says:
    2015-04-14 at 17:19

    I was searching the web how to connect this display with Arduino nano and this post has been very useful.
    Thank you very much for sharing.

    Reply
  2. Victor says:
    2015-05-18 at 20:29

    Thanks for sharing! Same issue as Manu but it works now. I’m wondering what is the most effective way to connect it instead of the diodes 4148.

    Reply
    1. rolfje says:
      2015-05-18 at 21:28

      The diodes are the simplest. The fet is electrically the best. The maxim level converters are the most work and more expensive, and I think they are just packaged versions of the get schematic you see in my post.

      Reply
  3. Gert says:
    2017-02-08 at 12:25

    can I use cd4050 ioc as converter?

    Reply
    1. rolfje says:
      2017-02-08 at 13:59

      Maybe if you can power it with 3v and connect two ports to make it non-inverting.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

           

Recent Comments

  • rolfje on Methode Buijs uitgelegd
  • LinkedIn is at Peak Enshittifaction – Will Chatham's Blog on Linked-In not really Opt-in?
  • Hans j on 1N4148 diode as RF switch
  • Roaming Rhonda on DLNA on OSX, done right
  • Frans on How to fix a Krups XN2001 Nespresso machine

Tags

Anonimatron Apple backup design DIY DRM eclipse environment Fun gmail google hacking hamradio Hardware helicopter iphone ipod iTunes Java Keynote maven modelling motorcycle music news opinion oracle osx photo photography programming repair review security Software Steve Jobs T-Mobile technology Time Machine Ubuntu usability Utilities vacation windows Workshop

Categories

  • Apple (105)
  • Divorce (1)
  • Electronics (3)
  • Fun (57)
  • Games (7)
  • Hardware (72)
  • Microsoft (18)
  • Racing (14)
  • Software (134)
  • Uncategorized (65)
  • Workshop (20)

Archives

Copyright © 2025 www.rolfje.com.

Powered by PressBook WordPress theme