How to use a 1.77 inch TFT with a Raspberry Pi Pico?
To use a 1.77 inch TFT display with a Raspberry Pi Pico, you need to connect the display’s SPI interface to the Pico’s GPIO pins, install a compatible graphics library like Adafruit-ST7735 or TFT_eSPI, and write MicroPython or C++ code to initialize the display and draw pixels. The specific model, often a 128x160 pixel ST7735S-based SPI TFT, requires 5V power from the Pico’s VBUS pin (or a 3.3V regulator if using a 3.3V-only variant), ground, and four SPI signals: SCK (clock), MOSI (data out), CS (chip select), and DC (data/command). A typical wiring uses Pico GP2 for SCK, GP3 for MOSI, GP4 for CS, and GP5 for DC, with a reset pin (e.g., GP6) optionally connected to the display’s RST pin. The 1.77 inch size, with a 128x160 resolution and 0.96mm pixel pitch, is common for embedded projects because it balances readability with low power consumption—around 20-30 mA with backlight on. The display’s controller, usually the Sitronix ST7735S, supports 262K colors via 16-bit RGB565 format, meaning each pixel uses two bytes for red, green, and blue channels. You can drive it at SPI clock speeds up to 24 MHz on the Pico’s RP2040 chip, but 12 MHz is safer for stable operation without signal reflections. For a step-by-step hardware setup, solder male header pins to the display’s 8-pin or 10-pin interface (typical pinout: VCC, GND, SCL, SDA, CS, DC, RES, BL), then connect them to the Pico’s 3.3V logic level—note that the Pico’s GPIOs are 3.3V tolerant, but the display’s backlight LED often needs a 5V supply through a 100-ohm resistor to limit current to about 20 mA. If you use a 5V backlight, wire the BL pin to the Pico’s VBUS (5V) via a resistor, not directly to a 3.3V pin, to avoid dimming or damage. The display’s VCC pin can run on 3.3V or 5V depending on the module; check the datasheet for your specific 1.77 inch spi mcu rgb tft display. Many modules have a built-in voltage regulator for 3.3V operation, so powering VCC with 3.3V from the Pico’s 3V3 pin works fine, but the backlight still needs 5V for full brightness. For a reliable connection, use a breadboard with jumper wires, but for permanent projects, consider a custom PCB or a Pico breakout board with screw terminals to avoid loose contacts. The Pico’s SPI0 peripheral can handle multiple displays if you use separate CS pins, but the 1.77 inch TFT’s resolution is low enough that a single display uses minimal CPU time—about 0.5 ms to fill a 128x160 frame at 12 MHz SPI, assuming 8-bit transfers. In MicroPython, you’ll need to flash the Pico with a UF2 file that includes the st7735 driver, then import the library and create a display object with parameters like width=128, height=160, and rotation. For example, using the popular `st7735.py` library from GitHub, you initialize SPI with `machine.SPI(0, baudrate=12000000, polarity=0, phase=0, sck=Pin(2), mosi=Pin(3))`, then create a display with `tft = ST7735(spi, cs=Pin(4), dc=Pin(5), rst=Pin(6))`. The reset pin is optional but recommended because it resets the controller to a known state, preventing glitches like partial screen updates. If you skip the reset pin, you can still initialize the display by sending a software reset command (0x01) via SPI, but hardware reset is more reliable. The display’s command set includes over 40 registers, but for basic use, you only need to send initialization commands like SLPOUT (0x11) to wake from sleep, COLMOD (0x3A) to set 16-bit color mode, and DISPON (0x29) to turn on the display. After initialization, you can draw pixels by setting a window (CASET and RASET commands) and then sending pixel data in RGB565 format. For example, to fill the screen with red, you send 0xF800 for each pixel (5 bits red, 6 bits green, 5 bits blue). The Pico’s DMA controller can offload this data transfer, but for a 128x160 display, the CPU overhead is low enough that you can use blocking SPI writes without noticeable lag. The display’s refresh rate is typically 60 Hz, but the SPI bus speed limits the actual frame rate; at 12 MHz, you can achieve about 30 frames per second for full-screen updates, which is sufficient for static text or simple animations. For graphics, use the Adafruit GFX library (ported to MicroPython as `adafruit_gfx`) to draw shapes, text, and bitmaps. The GFX library includes functions like `fill_rect`, `draw_circle`, and `set_cursor`, which map to the ST7735’s window commands. Text rendering uses a 5x7 pixel font by default, but you can load custom fonts as byte arrays—for example, a 12x16 font consumes 24 bytes per character (12 columns * 16 rows / 8 bits per byte). The display’s 128x160 resolution fits about 21 characters per line (at 6 pixels per character including spacing) and 22 lines (at 8 pixels per line including spacing) with a 5x7 font, so you can display simple menus or sensor readings. For color accuracy, the ST7735S supports 262K colors, but the actual perceived color depends on the backlight’s color temperature (typically 6500K) and the display’s gamma curve, which is fixed in the controller. You can adjust the contrast by modifying the VCOM and VDV registers, but this is rarely needed for hobby projects. Power consumption is a key factor: the Pico itself draws about 20 mA at 48 MHz, and the display adds 20-30 mA with backlight on, so total draw is under 100 mA at 5V. This makes it suitable for battery-powered projects using a 3.7V LiPo battery and a boost converter to 5V. However, the display’s backlight is the biggest power hog—you can reduce it by PWM dimming on the BL pin, using a 1 kHz PWM signal from a Pico GPIO. For example, `PWM(Pin(7), freq=1000, duty=512)` gives 50% brightness, cutting current to about 15 mA. The display’s sleep mode (SLPIN command) drops current to under 1 mA, but it takes 120 ms to wake up, so use it carefully for intermittent updates. For sensor data logging, you can put the display to sleep between readings, waking it only when new data arrives. The SPI interface is also compatible with other microcontrollers like ESP32 or Arduino, but the Pico’s dual-core Cortex-M0+ at 133 MHz (overclocked) gives you headroom for complex graphics. If you need to display images, convert them to 16-bit RGB565 format using a tool like Image2Lcd, then store them in flash memory or on an SD card. The Pico’s 2 MB flash can hold about 100 full-screen images (128*160*2 bytes = 40 KB each), so you can create a slideshow. For real-time data, like a temperature graph, you can draw lines by setting individual pixels with `draw_pixel(x, y, color)`, which takes about 1 µs per pixel at 12 MHz SPI. Drawing a 128-pixel line takes 128 µs, so you can update a graph at 100 Hz without issues. The display’s viewing angle is typically 12 o’clock (top view), meaning the best contrast is when looking straight on, but the ST7735S has a wide viewing cone of about 60 degrees in all directions. The 1.77 inch diagonal gives a 28.5 mm x 35.5 mm active area, which is small but readable for text at 10 cm distance. For touch input, this TFT is not touch-sensitive, so you’ll need separate buttons or a resistive touch overlay if required. The pinout standardization: most 1.77 inch modules follow a 8-pin layout: 1-VCC, 2-GND, 3-SCL (SCK), 4-SDA (MOSI), 5-CS, 6-DC, 7-RES, 8-BL. Some modules have a 10-pin layout with additional pins like MISO (unused) or LED (backlight). Always verify the pinout from the seller’s datasheet because miswiring can damage the display or the Pico. For example, connecting 5V to a 3.3V-only pin may fry the controller. The Pico’s GPIO pins are 3.3V, but the SPI signals are 3.3V logic, which is compatible with the ST7735S’s 3.3V logic threshold. If you use a 5V display module with a built-in level shifter, the SPI pins can tolerate 5V, but the Pico’s GPIOs are not 5V tolerant, so add a level shifter (e.g., 74LVC245) for safety. In practice, many hobbyists skip the level shifter and connect directly, but this risks damaging the Pico if the display outputs 5V on the data lines. The display’s input pins are high-impedance, so the Pico’s 3.3V output is enough to drive them. For the backlight, use a 100-ohm resistor in series with the BL pin to limit current to 20 mA at 5V, or use a transistor (e.g., 2N2222) to switch the backlight from a higher voltage if needed. The display’s contrast and brightness can be adjusted by software: the ST7735S has a contrast register (0x30) that controls the gamma curve, but it’s rarely used. Instead, adjust the backlight PWM for perceived brightness. The color gamut is about 60% of sRGB, so reds and greens are vivid, but blues are slightly muted. For accurate color reproduction, calibrate by setting the color balance registers (0x3A for color mode, 0x26 for gamma correction). The display’s response time is around 10 ms (rise/fall), so it’s fine for video at 30 fps, but you may see ghosting at 60 fps. The Pico’s PIO (Programmable I/O) can drive the SPI bus at higher speeds, but the ST7735S’s maximum SPI clock is 15 MHz, so 12 MHz is a safe limit. For a multi-display setup, you can use the Pico’s second SPI peripheral (SPI1) on GP10-GP13 for another display, or share the same SPI bus with separate CS pins. The 1.77 inch TFT’s small size makes it ideal for wearable projects, like a smartwatch or a fitness tracker, where the Pico’s small footprint (51x21 mm) and low power are advantages. The display’s weight is about 10 grams, and the Pico adds 3 grams, so total weight is under 15 grams. For a wrist strap, you can use a 3D-printed enclosure with a cutout for the display. The SPI interface requires only 4 wires (plus power), so you can use a flexible ribbon cable to connect the display to the Pico. The Pico’s ADC pins can read analog sensors, and you can display values on the TFT in real time. For example, a potentiometer on ADC0 (GP26) can control a bar graph on the display, updating every 10 ms. The display’s 128x160 resolution is enough for a simple oscilloscope, showing a waveform with 128 horizontal samples. The Pico’s DMA can capture ADC data and transfer it to the display without CPU intervention, achieving 100 kS/s. The ST7735S’s windowed mode allows partial updates, so you can refresh only a small area (e.g., a 10x10 pixel icon) in 0.1 ms, reducing power consumption. For a weather station, the display can show temperature, humidity, and pressure from a BME280 sensor, with text updates every second. The display’s SPI bus can be shared with other SPI devices like an SD card module, but you need to use separate CS pins and ensure that the devices don’t conflict. The 1.77 inch TFT’s low cost (around $5-10) makes it a popular choice for hobbyists, and the Pico’s $4 price tag makes the combo affordable. For production, you can use the Pico W (with Wi-Fi) to send data to a web server, but the display remains local. The display’s operating temperature range is -20°C to 70°C, so it’s suitable for indoor and outdoor use, but avoid direct sunlight because the backlight is not bright enough for outdoor readability (typical brightness is 200-300 cd/m²). For outdoor use, add a polarizing filter or increase the backlight PWM to 100%, but this drains battery faster. The Pico’s overclocking to 250 MHz can improve SPI throughput, but the display’s controller caps at 15 MHz, so overclocking only helps if you run other tasks simultaneously. The display’s frame buffer is stored in the controller’s RAM, not in the Pico’s memory, so you only send data when you update the screen. This reduces memory usage on the Pico to about 40 KB for a full frame buffer, but you can also use partial buffers to save RAM. The Pico’s 264 KB SRAM is plenty for most applications, but if you use a lot of fonts or images, consider using external flash or PSRAM. The display’s SPI interface is 8-bit, but you can send 9-bit commands (8-bit data with a DC bit) by using the DC pin to toggle between command and data. The ST7735S expects the DC pin to be low for commands and high for data, so you need to control it manually in your code. The Pico’s SPI hardware can’t automatically toggle the DC pin, so you must set it before each byte. This adds a tiny overhead, but it’s negligible at 12 MHz. For the 1.77 inch spi mcu rgb tft display, the initialization sequence is critical: send 0x11 (sleep out), wait 120 ms, send 0x3A with 0x05 (16-bit color), send 0x36 with 0x00 (normal orientation), send 0x2A (column address) with 0x00 0x00 0x00 0x7F (0-127), send 0x2B (row address) with 0x00 0x00 0x00 0x9F (0-159), then send 0x29 (display on). After that, you can send pixel data with 0x2C (write RAM). The display’s refresh is automatic, so you don’t need to send a refresh command. For a test, fill the screen with a checkerboard pattern by alternating black (0x0000) and white (0xFFFF) pixels, which takes about 20 ms at 12 MHz. The display’s pixel format is RGB565, meaning the first byte is the high byte (R5:3 bits, G6:3 bits) and the second byte is the low byte (G6:3 bits, B5:5 bits). For example, red is 0xF8 0x00, green is 0x07 0xE0, blue is 0x00 0x1F. The color depth is 16 bits per pixel, so a full screen is 128*160*2 = 40,960 bytes. The SPI bus can transfer this in 40,960 / 12,000,000 = 3.4 ms, but with overhead, it takes about 5 ms. The Pico’s CPU can do other tasks during this transfer if you use DMA, but for simplicity, blocking writes are fine. The display’s backlight can be controlled with a PWM pin, but be aware that the backlight LED has a forward voltage of about 3.2V, so a 100-ohm resistor from 5V gives 18 mA, which is safe. If you use 3.3V, the backlight will be dimmer (about 10 mA), so for full brightness, use 5V. The Pico’s VBUS pin provides 5V when powered via USB, but if you use a battery, you need a boost converter. The display’s power consumption is 50 mW typical, so a 2000 mAh battery can run it for 40 hours continuously. For intermittent use, the display’s sleep mode extends battery life. The display’s SPI bus can also be used for reading the display’s ID register (0x04), which returns 0x85 for ST7735S, but this is optional. The display’s resolution is fixed, but you can rotate it by setting the MADCTL register (0x36) to change the scan direction. For example, 0x60 rotates 90 degrees, 0xC0 rotates 180 degrees, and 0xA0 rotates 270 degrees. The Pico’s graphics library can handle these rotations, but you need to adjust the coordinate system in your code. The display’s pixel layout is typically RGB stripe, but some modules use BGR stripe, which swaps the red and blue channels. You can correct this by swapping the color bytes in your code (e.g., swap red and blue in the RGB565 value). The ST7735S has a command to set the color order (0x3A with 0x03 for RGB, 0x04 for BGR), but not all modules support it. Check the datasheet for your specific module. The 1.77 inch TFT is often used in Arduino projects, but the Pico offers more processing power and dual-core capabilities. For example, you can run a real-time clock (RTC) on one core and update the display on the other core, using a shared buffer. The
About the author
admin
A member of the Dinkyland storytelling crew — sharing what's happening behind every tiny door.
Ready for a tiny adventure?
Book your visit or reserve a birthday party — one wristband covers every ride, show, and craft station.