Home Assistant Smart Home (ESP32C6 with Display)

Introduction: Previously, I used a 1.3-inch I2C display, which was indeed small and caused eye strain. Now, I have switched to a 2.8-inch TFT display driven by ILI9341, which allows for larger font sizes and clearer visibility.

nanoesp32c6 2.8-inch ILI9341 driven
VCC 3.3V
GND GND
CS 10
RESET 9
DC 8
MOSI 11
SCK 12
LED 3.3V Connected to VCC
MISO 13 Not required for display
/***************************************************  NanoESP32C6 module connected to 2.8-inch TFT driven by ILI9341 for pure display output ****************************************************/#include "SPI.h"#include "Adafruit_GFX.h"#include "Adafruit_ILI9341.h"// For the Adafruit shield, these are the default.#define TFT_DC 8   //#define TFT_CS 10#define  TFT_RST 9 ////#define TFT_MISO 13 // Not required#define TFT_MOSI 11#define TFT_CLK 12
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST);// If using MISO, it needs to be added in void setup() {  Serial.begin(115200);  tft.begin(); // Screen initializationtft.fillScreen(ILI9341_BLACK); // Black background, otherwise it will show a zebra background  tft.setCursor(10, 20); // Coordinates  tft.setRotation(3); // Font display angle   tft.setTextColor(ILI9341_RED);    tft.setTextSize(3);  tft.println("OK HHHH"); // Red font, size 3, content OK HHHH
displayBasicChars(); // Custom display content
drawString(tft, "Custom DrawString", 120, 10, ILI9341_WHITE, 2);// Using custom display format parameters  delay(1000);//  Serial.println(F("Done!"));}
// When the library does not have the required format, custom display format parameters are neededvoid drawString(Adafruit_ILI9341 &display, const String &str, int x, int y, uint16_t color, uint8_t size) {  display.setTextColor(color);  display.setTextSize(size);  display.setCursor(x, y);  display.print(str);}
void loop() {
}
// Use drawChar to display stringsvoid displayBasicChars() {  // Different sizes of characters (X mark, Y mark, content, font color, background color, font size)  tft.drawChar(100, 40, '4', ILI9341_ORANGE, ILI9341_BLACK, 4);  // Character with background color  tft.drawChar(90, 80, 'Z', ILI9341_WHITE, ILI9341_BLUE, 3);}

Leave a Comment