Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use Adafruit 2.2in PiTFT HAT: Examples, Pinouts, and Specs

Image of Adafruit 2.2in PiTFT HATDesign with Adafruit 2.2in PiTFT HAT in Cirkit Designer

Introduction

The Adafruit 2.2in PiTFT HAT is a compact and versatile display module featuring a 2.2-inch TFT LCD screen with a resolution of 320x240 pixels. This HAT (Hardware Attached on Top) is specifically designed for compatibility with the Raspberry Pi, making it an excellent choice for projects that require a small display with good resolution and color representation. Common applications include handheld devices, mini gaming consoles, and user interfaces for various Raspberry Pi projects.

Explore Projects Built with Adafruit 2.2in PiTFT HAT

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Raspberry Pi 4B-Based Multi-Sensor Interface Hub with GPS and GSM: A project utilizing Adafruit 2.2in PiTFT HAT in a practical application
Raspberry Pi 4B-Based Multi-Sensor Interface Hub with GPS and GSM

This circuit features a Raspberry Pi 4B interfaced with an IMX296 color global shutter camera, a Neo 6M GPS module, an Adafruit BMP388 barometric pressure sensor, an MPU-6050 accelerometer/gyroscope, and a Sim800l GSM module for cellular connectivity. Power management is handled by an MT3608 boost converter, which steps up the voltage from a Lipo battery, with a resettable fuse PTC and a 1N4007 diode for protection. The Adafruit Perma-Proto HAT is used for organizing connections and interfacing the sensors and modules with the Raspberry Pi via I2C and GPIO pins.

Open Project in Cirkit Designer
Image of Raspberry Pi 5 Smart Weather Station with GPS and AI Integration: A project utilizing Adafruit 2.2in PiTFT HAT in a practical application
Raspberry Pi 5 Smart Weather Station with GPS and AI Integration

This circuit integrates a Raspberry Pi 5 with various peripherals including an 8MP 3D stereo camera, an AI Hat, a BMP388 sensor, a 16x2 I2C LCD, and an Adafruit Ultimate GPS module. The Raspberry Pi serves as the central processing unit, interfacing with the camera for image capture, the AI Hat for AI processing, the BMP388 for environmental sensing, the LCD for display, and the GPS module for location tracking, with a USB Serial TTL for serial communication.

Open Project in Cirkit Designer
Image of Raspberry Pi Pico and OV7670 Camera-Based Robotic System with TFT Display: A project utilizing Adafruit 2.2in PiTFT HAT in a practical application
Raspberry Pi Pico and OV7670 Camera-Based Robotic System with TFT Display

This circuit features two Raspberry Pi Pico microcontrollers interfacing with various peripherals including an OV7670 camera module, a TFT display, and an OLED display. It also includes a multiplexer and a motor driver to control two planetary gearbox motors, powered by a battery and regulated through buck converters. The setup is designed for image capture, display, and motor control applications.

Open Project in Cirkit Designer
Image of Raspberry Pi 4B with I2C Current Sensing and OLED Display: A project utilizing Adafruit 2.2in PiTFT HAT in a practical application
Raspberry Pi 4B with I2C Current Sensing and OLED Display

This circuit features a Raspberry Pi 4B as the central processing unit, interfaced with an Adafruit ADS1115 16-bit I2C ADC for analog-to-digital conversion and a 0.96" OLED display for visual output. The ADC is connected to a current sensor for measuring electrical current, with the sensor's output connected to the ADC's AIN0 pin and the burden resistor connected to AIN1. The Raspberry Pi communicates with both the ADC and the OLED display over the I2C bus, using GPIO2 (SDA) and GPIO3 (SCL) for data exchange.

Open Project in Cirkit Designer

Technical Specifications

Display Characteristics

Electrical Specifications

Pin Configuration and Descriptions

Pin Number Name Description
1 3V3 3.3V Power Supply
2 5V 5V Power Supply (for backlight)
3 GND Ground
4 MOSI SPI Data Input to TFT
5 SCLK SPI Clock to TFT
6 CS SPI Chip Select for TFT
7 RST Reset Pin for TFT
8 D/C Data/Command Control Pin

Usage Instructions

Connecting to Raspberry Pi

  1. Power Off Raspberry Pi: Ensure that your Raspberry Pi is turned off before connecting the PiTFT HAT.
  2. Align Pins: Carefully align the GPIO pins of the PiTFT HAT with the corresponding pins on the Raspberry Pi.
  3. Attach the HAT: Gently press down on the PiTFT HAT to connect it to the Raspberry Pi GPIO header.

Software Configuration

To use the Adafruit 2.2in PiTFT HAT with your Raspberry Pi, you'll need to install the necessary software and configure the Pi to use the display.

  1. Install Adafruit Helper: Run the following commands in the terminal to install the Adafruit helper utility:
cd ~
sudo apt-get update
sudo apt-get install -y git python3-pip
git clone https://github.com/adafruit/Raspberry-Pi-Installer-Scripts.git
cd Raspberry-Pi-Installer-Scripts
sudo python3 adafruit-pitft.py
  1. Follow On-Screen Prompts: The installation script will guide you through the setup process. Choose the appropriate options for your PiTFT model and desired configuration.

  2. Reboot: Once the installation is complete, reboot your Raspberry Pi.

Testing the Display

After installation and configuration, you can test the display using the following Python script:

import os
import pygame
import time
import random

# Initialize the display
os.putenv('SDL_FBDEV', '/dev/fb1')
pygame.init()

# Set up the display surface
size = (320, 240)
pygame.display.set_mode(size)
screen = pygame.display.get_surface()

# Fill the screen with red, green, blue, and then black
colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (0, 0, 0)]
for color in colors:
    screen.fill(color)
    pygame.display.flip()
    time.sleep(1)

Important Considerations and Best Practices

Troubleshooting and FAQs

Common Issues

Solutions and Tips

FAQs

Q: Can I use the PiTFT HAT with any Raspberry Pi model? A: The PiTFT HAT is compatible with most Raspberry Pi models with a 40-pin GPIO header. Check the Adafruit website for specific model compatibility.

Q: How do I calibrate the touchscreen? A: If your PiTFT HAT includes a touchscreen, you can calibrate it using the adafruit-pitft-touch-cal script found in the Raspberry-Pi-Installer-Scripts repository.

Q: Can I use the PiTFT HAT with other operating systems besides Raspbian? A: The PiTFT HAT is designed to work with Raspbian, but it may work with other Raspberry Pi-compatible operating systems. Check the documentation for your specific OS for compatibility.

For further assistance, visit the Adafruit support forums or contact Adafruit customer service.