Esp32Lcd
Esp32Lcd
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Note
The module voltage is 3.3V and voltage divider is required to interface it with Arduino.
p://www.lcdwiki.com/2.8inch_SPI_Module_ILI9341_SKU:MSP2807
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
T_DIN: Touch SPI bus input
T_DO: Touch SPI bus input
T_IRQ: Touch screen interrupt signal, low level when touch is detected
SD-MOSI: SPI bus write data signal
SD-MISO: SPI bus read data signal, if you do not need to the read function, you can not connect it
SD-SCK: SPI bus clock signal
SD-CS: Chip select signal for SPI protocol (SD Card)
equired Materials
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
ardware Components
SP32 × 1
oftware Apps
rduino IDE
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
ep 2: Library
ensure seamless compatibility, install the TFT_eSPI library in the Arduino IDE using the following link:
ps://github.com/Bodmer/TFT_eSPI
er that, go to the address of installed library and open the User_Setup.h file and refer to line
IT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP
d uncomment the following lines and comment on the lines which are uncommented.
efine TFT_MISO 19
efine TFT_MOSI 23
efine TFT_SCLK 18
u can also download the ready file from here, unzip it and use in your project.
ep 3: Code
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
load the following code to your ESP32 microcontroller.
1 /*
2 Example animated analogue meters using a ILI9341 TFT LCD screen
3
4 Needs Font 2 (also Font 4 if using large scale label)
5
6 Make sure all the display driver and pin comnenctions are correct by
7 editting the User_Setup.h file in the TFT_eSPI library folder.
8
9 #########################################################################
10 ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
11 #########################################################################
12 */
13
14 #include <TFT_eSPI.h> // Hardware-specific library
15 #include <SPI.h>
16
17 TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
18
19 #define TFT_GREY 0x5AEB
20
s code serves as a test script, showcasing various graphical shapes and designs on the display. Verify the successful integration of th
play by observing the displayed visuals.
t ready to explore the possibilities of the 2.8 Inch TFT LCD display with touch screen capability and unleash your creativity in your ESP3
ojects.
Comments (19)
john
please explain, dumbass. how do you connect 3 pins from the required materials with one wire? fucking copy-paste
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
December 18, 2022 at 1:33 pm Reply
Kevin Reply
Thanks for the post. It worked for me right away. Saved me a lot of time.
Ron Reply
This worked on the the first go around. That never happens with me. LOL
Thanks for the excellent presentation and fine business graphic demo display.
Very Nice!
summer Reply
Hi,
Do ou have done any touch function testing?
Thanks
summer
Richard Reply
I have set up as per your diagram except for the touch, but all I get is a blank white screen, I wonder how it worked for
some folks, Any suggestions?
lkat Reply
Hello, I’ve coded a tft 2.8 touchscreen LCD with an Arduino uno; using the
SPI and #include
#include
#include ,
libraries to code it
I recently learnt about the esp23, and i was wondering if it will work if i just transfer the wiring to it
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Mohammad Damirchi Reply
Hello
Can you send just the library name? In your message, after “include,” there’s nothing.
Also, if you’re referring to the MCUfriend or Adafruit library, I recommend using TFT_eSPI for ESP to achieve better
results.
The two libraries for Arduino often don’t function properly with ESP, or they might lead to issues.
Sameerudeen Reply
Hi sir, I made connection by your circuit diagram and I only get white screen sir .
Do I get you WhatsApp numbers for clarification of doubt sir
Sameerudeen Reply
Hi,sir
I have configured correctly sir.but I did mistake is wiring after I made wiring perfectly and made user setup file
correctly then I got the display sir thank you so much for your guidance. Sir
Sir now I have problem to make touch. I used Adafruit_FT6206 library on my final year project entirely on simulation
(WOKWI SIMULATOR) . But in real time I cannot configure this library to my project .sir
Sameerudeen Reply
Thank you sir , the display working perfectly. I get the proper touching coordinates and mapping. 😁😁😁😁😁😁😁
April 22, 2024 at 1:53 pm
Shaiguy96 Reply
Hello, I am stuck with a white screen. i am using waveshare esp32-s3-nano https://www.waveshare.com/esp32-s3-
nano.htm. and i changed the pin configuration in the set up as the micro controller doesnt hace the designated GPIO
numbers in the regualr setup. and no matter how i change it i cannot get the screen to display anything but a white screen.
please help!
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
pinout according to your setup. Keep in mind that the pins for TFT_MOSI, TFT_SCLK, and TFT_MISO should remain as 11, 12, and 13
respectively. You can modify the other pins as needed.
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
/*
Example animated analogue meters using a ILI9341 TFT LCD screen
Make sure all the display driver and pin comnenctions are correct by
editting the User_Setup.h file in the TFT_eSPI library folder.
#########################################################################
###### DON’T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
#########################################################################
*/
void setup(void) {
tft.init();
tft.setRotation(0);
Serial.begin(57600); // For debug
tft.fillScreen(TFT_BLACK);
void loop() {
if (updateTime <= millis()) {
updateTime = millis() + LOOP_PERIOD;
d += 4; if (d >= 360) d = 0;
plotPointer();
plotNeedle(value[0], 0);
// #########################################################################
// Draw the analogue meter on the screen
// #########################################################################
void analogMeter()
{
// Meter outline
tft.fillRect(0, 0, 239, 126, TFT_GREY);
tft.fillRect(5, 3, 230, 119, TFT_WHITE);
// Draw ticks every 5 degrees from -50 to +50 degrees (100 deg. FSD swing)
for (int i = -50; i < 51; i += 5) {
// Long scale tick length
int tl = 15;
// Draw tick
tft.drawLine(x0, y0, x1, y1, TFT_BLACK);
// #########################################################################
// Update needle position
// This function is blocking while needle moves, time depends on ms_delay
// 10ms minimises needle flicker if text is drawn within needle sweep area
// Smaller values OK if text not in sweep area, zero for instant movement but
// does not look realistic... (note: 100 increments for full scale deflection)
// #########################################################################
void plotNeedle(int value, byte ms_delay)
{
tft.setTextColor(TFT_BLACK, TFT_WHITE);
char buf[8]; dtostrf(value, 4, 0, buf);
tft.drawRightString(buf, 40, 119 - 20, 2);
if (value < -10) value = -10; // Limit value to emulate needle end stops
if (value > 110) value = 110;
float sdeg = map(old_analog, -10, 110, -150, -30); // Map value to angle
// Calcualte tip of needle coords
float sx = cos(sdeg * 0.0174532925);
float sy = sin(sdeg * 0.0174532925);
// Draw the needle in the new postion, magenta makes needle a bit bolder
// draws 3 lines to thicken needle
tft.drawLine(120 + 20 * ltx - 1, 140 - 20, osx - 1, osy, TFT_RED);
tft.drawLine(120 + 20 * ltx, 140 - 20, osx, osy, TFT_MAGENTA);
tft.drawLine(120 + 20 * ltx + 1, 140 - 20, osx + 1, osy, TFT_RED);
// #########################################################################
// Draw a linear meter on the screen
// #########################################################################
void plotLinear(char *label, int x, int y)
{
int w = 36;
tft.drawRect(x, y, w, 155, TFT_GREY);
tft.fillRect(x + 2, y + 19, w - 3, 155 - 38, TFT_WHITE);
tft.setTextColor(TFT_CYAN, TFT_BLACK);
tft.drawCentreString(label, x + w / 2, y + 2, 2);
// #########################################################################
// Adjust 6 linear meter pointer positions
// #########################################################################
void plotPointer(void)
{
int dy = 187;
byte pw = 16;
tft.setTextColor(TFT_GREEN, TFT_BLACK);