Skip to content

Instantly share code, notes, and snippets.

@MazeW
Created January 9, 2022 13:09
Show Gist options
  • Save MazeW/87b5115c2286b77e163957d6b360165f to your computer and use it in GitHub Desktop.
Save MazeW/87b5115c2286b77e163957d6b360165f to your computer and use it in GitHub Desktop.

Connect ST7789 to ESP32

Wiring

ESP32 ST7789
GND GND
3v3 VCC
D18 SCL
D23 SDA
D4 RES
D2 DC
/ BLK

Code

#include <Arduino.h>
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_I2CDevice.h>
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>             // Arduino SPI library

#define TFT_MOSI 23  // SDA Pin on ESP32
#define TFT_SCLK 18  // SCL Pin on ESP32
#define TFT_CS   15  // Chip select control pin
#define TFT_DC    2  // Data Command control pin
#define TFT_RST   4  // Reset pin (could connect to RST pin)


// Initialize Adafruit ST7789 TFT library
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
 
void setup(void) {
  Serial.begin(115200);
  tft.init(240, 240, SPI_MODE2);    // Init ST7789 display 135x240 pixel
  tft.setRotation(2);
  tft.fillScreen(ST77XX_BLACK); // fills the screen with black colour
  tft.setCursor(10, 10); // starts to write text at y10 x10
  tft.setTextColor(ST77XX_WHITE); // text colour to white you can use hex codes like 0xDAB420 too
  tft.setTextSize(3); // sets font size
  tft.setTextWrap(true);
  tft.print("HELLO WORLD!");
}
 
void loop() {

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment