ESP32 écran tactile 2.8 pouces TFT LCD affichage ESP-WROOM-32 ILI9341 tactile résistif technologie 240*320 ESP32-2432S028R Bluetooth WIFI AliExpress
Hi all,
I recently bought ESP32-3248S035 (https://tinyurl.com/nwttm4xw 33) and trying to get the right configuration to get it up and running (screen/touch).
Did anyone have any success in that?
Thank you so much!
nickrout
Regular
Jul 10
There is some info here, and it does say they have psram. ESP32-3248S035 - openHASP 39
clydebarrow
Clyde Stubbs
Jul 10
That page says 8MB PSRAM at the top, but later in 2 places it says no PSRAM.
yatush
Jul 10
Thanks for the help, I’ve tried setting the configuration, and get the following:
[23:40:00][C][logger:185]: Logger:
[23:40:00][C][logger:186]: Level: DEBUG
[23:40:00][C][logger:188]: Log Baud Rate: 115200
[23:40:00][C][logger:189]: Hardware UART: UART0
[23:40:00][C][spi:068]: SPI bus:
[23:40:00][C][spi:069]: CLK Pin: GPIO14
[23:40:00][C][spi:070]: SDI Pin: GPIO12
[23:40:00][C][spi:071]: SDO Pin: GPIO13
[23:40:00][C][spi:076]: Using HW SPI: SPI
[23:40:00][C][spi:068]: SPI bus:
[23:40:00][C][spi:069]: CLK Pin: GPIO18
[23:40:00][C][ledc.output:181]: Bit depth: 16
[23:40:00][C][ledc.output:176]: LEDC Output:
[23:40:00][C][ledc.output:177]: Pin GPIO4
[23:40:00][C][ledc.output:178]: LEDC Channel: 1
[23:40:00][C][ledc.output:179]: PWM Frequency: 1000.0 Hz
[23:40:00][C][ledc.output:180]: Phase angle: 0.0°
[23:40:00][C][ledc.output:181]: Bit depth: 16
[23:40:00][C][ledc.output:176]: LEDC Output:
[23:40:00][C][ledc.output:177]: Pin GPIO16
[23:40:00][C][ledc.output:178]: LEDC Channel: 2
[23:40:00][C][ledc.output:179]: PWM Frequency: 1000.0 Hz
[23:40:00][C][ledc.output:180]: Phase angle: 0.0°
[23:40:00][C][ledc.output:181]: Bit depth: 16
[23:40:00][C][ledc.output:176]: LEDC Output:
[23:40:00][C][ledc.output:177]: Pin GPIO17
[23:40:00][C][ili9xxx:094]: Dimensions: 320px x 480px
[23:40:00][C][ili9xxx:095]: Width Offset: 0
[23:40:00][C][ili9xxx:105]: Color mode: 8bit 332 mode
[23:40:00][C][ili9xxx:111]: Data rate: 40MHz
[23:40:00][C][ili9xxx:114]: CS Pin: GPIO15
[23:40:00][C][ili9xxx:115]: DC Pin: GPIO2
[23:40:00][C][ili9xxx:117]: Color order: BGR
[23:40:00][C][ili9xxx:118]: Swap_xy: NO
[23:40:00][C][ili9xxx:119]: Mirror_x: YES
[23:40:00][C][ili9xxx:120]: Mirror_y: NO
[23:40:00][C][ili9xxx:123]: => Failed to init Memory: YES!
[23:40:00][C][ili9xxx:125]: Update Interval: 1.0s
[23:40:00][E][component:082]: Component display is marked FAILED
[23:40:00][C][light:103]: Light ‹ LED ›
[23:40:00][C][light:105]: Default Transition Length: 1.0s
[23:40:00][C][light:106]: Gamma Correct: 2.80
[23:40:00][C][esp32_improv.component:261]: ESP32 Improv:
[23:40:00][C][esp32_improv.component:266]: Status Indicator: ‹ NO ›
[23:40:00][C][captive_portal:088]: Captive Portal:
[23:40:00][C][web_server:173]: Web Server:
[23:40:00][C][web_server:174]: Address: esphome-web-4560ec.local:80
[23:40:00][C][mdns:115]: mDNS:
[23:40:00][C][mdns:116]: Hostname: esphome-web-4560ec
[23:40:00][C][esphome.ota:073]: Over-The-Air updates:
[23:40:00][C][esphome.ota:074]: Address: esphome-web-4560ec.local:3232
[23:40:00][C][esphome.ota:075]: Version: 2
[23:40:00][C][safe_mode:018]: Safe Mode:
[23:40:00][C][api:140]: Address: esphome-web-4560ec.local:6053
The configuration I’m using is:
spi:
- id: tft
clk_pin: GPIO14
mosi_pin: GPIO13
miso_pin: GPIO12
- id: touch
clk_pin: GPIO18
mosi_pin: GPIO23
miso_pin: GPIO19
display:
- platform: ili9xxx
model: ST7796
cs_pin: GPIO15
dc_pin: GPIO2
spi_id: tft
Any thoughts what I still might be missing?
Thanks!
nickrout
Regular
clydebarrow
Jul 10
Yes, you are right, that needs fixing doesn’t it, and careful reading.
clydebarrow
Clyde Stubbs
Jul 10
Like I said, it won’t work with the standard display operations due to insufficient memory. You’ll need update_interval: never and auto_clear_enabled: false then use LVGL - LVGL implementation for ESPHome by clydebarrow · Pull Request #6363 · esphome/esphome · GitHub 24 - read the docs linked there and make sure to set buffer_size: 25%
Also best to log via UART so you capture all the messages after startup.
Jul 25
I struggled getting this to work as well, but it works fine with Openhasp if you want it to just work. I’ve realised I’m not a big fan of that software though and I also plan to add some controls to the device which would be easier using Esphome.
[edit]: I forgot to change the buffer size, now it works!
So I tried @clydebarrow’s suggestions and that works. I used the following yaml for a hello world example:
esphome:
name: tv-controller
friendly_name: TV-controller
external_components:
- source: github://pr#6363
refresh: 10min
components: [lvgl]
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
api:
encryption:
key: "xxx"
ota:
platform: esphome
password: "xxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
i2c:
sda: 33
scl: 32
scan: true
id: bus_a
spi:
clk_pin: 14
mosi_pin: 13
miso_pin: 12
light:
- platform: rgb
name: "Status Light"
red: red_GPIO
green: green_GPIO
blue: blue_GPIO
- platform: monochromatic
output: backlight_pin
name: "Display Backlight"
id: back_light
restore_mode: ALWAYS_ON
output:
- platform: ledc
pin: 4
id: red_GPIO
inverted: True
- platform: ledc
pin: 16
id: green_GPIO
inverted: True
- platform: ledc
pin: 17
id: blue_GPIO
inverted: True
- platform: ledc
pin: 27
id: backlight_pin
display:
- platform: ili9xxx
id: my_display
model: ST7796
dc_pin: 2
cs_pin: 15
dimensions: 320x480
update_interval: never
auto_clear_enabled: false
touchscreen:
platform: gt911
id: my_touch
update_interval: 50ms
# interrupt_pin: 21 # maybe not connected?
# reset_pin: 25 # From a openhasp config, appears to be the 'normal' esp32 reset pin?
color:
- id: my_red
red: 100%
green: 0%
blue: 0%
# font:
# - file: "gfonts://Martian+Mono"
# id: large
# size: 40
# - file: "gfonts://Martian+Mono"
# id: small
# size: 20
lvgl:
touchscreens:
- my_touch
buffer_size: 25%
pages:
- id: main_page
widgets:
- label:
align: CENTER
text: 'Hello World!'
25d
For all attempting to use the ESP32-3248S035C (or ESP32-3248S035R)
For Touch on these boards the following applies (GPIO Pins):
Resistive Touch : INT = 36, SCLK = 14, MOSI = 13, MISO =12, CS = 33 (XPT2046)
Capacitative Touch: INT = 21, SCL = 32, SDA = 33, RST = 25 (GT911)
The Resistive Touch needs to align the touchscreen before it can be used whereas the Capacitive Touch does not need this Step as it is prealigned.
LED1 has three GPIO pins : RED = 4, GREEN = 16, BLUE = 17
BACKLIGHT = GPIO 27
AUDIO AMP : GPIO 26 - Careful when using a speaker an 8 ohm speaker needs to have a series resistor to prevent overloading the amp.
GPIO 39 is unwired but can still be used
Careful with Capacitive Touch - pin 21 has two other definitions (min)
SCREEN SPI: DC = 2, SCLK = 14, MOSI = 13, MISO = 12, CS = 15 RST = EN(-1) - Please note the Screen SPI and Resistive Touch share SCLK, MOSI, & MISO
This board does not act like other ESP32 boards as many of the pins are hard wired and predefined. However , If you prefer easier manipulation / programming of this board go to Annex 32 Rapid Development Suite and use the BASIC Language where this board and its large number of capabilities are all accessible.
This is great board have fun.
I hope that this helps
#définir ST7796_DRIVER
#définir TFT_WIDTH 320
#définir TFT_HEIGHT 480 //
#define TFT_BL 27 // Broche de commande du rétroéclairage LED
#define TFT_BACKLIGHT_ON HIGH // Niveau pour activer le rétroéclairage (HIGH ou LOW)
#définir TFT_MISO 12
#define TFT_MOSI 13 // Dans certaines cartes de pilotes d'affichage, il peut être écrit comme "SDA" et ainsi de suite.
#définir TFT_SCLK 14
#define TFT_CS 15 // Broche de contrôle de sélection de puce
#define TFT_DC 2 // Broche de contrôle de la commande de données
#define TFT_RST -1 // Réinitialiser la broche (pourrait se connecter à la broche Arduino RESET)
#define TFT_BL 27 // Rétroéclairage LED
#define TOUCH_CS 33 // Broche de sélection de puce (T_CS) de l'écran tactile
#define LOAD_GLCD // Police 1. La police originale Adafruit de 8 pixels nécessite ~ 1820 octets en FLASH
#define LOAD_FONT2 // Police 2. Petite police de 16 pixels de haut, nécessite ~3534 octets en FLASH, 96 caractères
#define LOAD_FONT4 // Police 4. Police moyenne de 26 pixels de haut, nécessite ~ 5848 octets en FLASH, 96 caractères
#define LOAD_FONT6 // Police 6. Grande police de 48 pixels, nécessite ~ 2666 octets en FLASH, uniquement les caractères 1234567890:-.apm
#define LOAD_FONT7 // Police 7. Police à 7 segments de 48 pixels, nécessite ~ 2438 octets en FLASH, uniquement les caractères 1234567890:-.
#define LOAD_FONT8 // Police 8. Une grande police de 75 pixels nécessite ~ 3256 octets en FLASH, uniquement les caractères 1234567890:-.
#define LOAD_GFXFF // FreeFonts. Inclut l'accès aux 48 polices gratuites Adafruit_GFX FF1 à FF48 et aux polices personnalisées
#définir SMOOTH_FONT
#définir SPI_FREQUENCY 65000000
#définir SPI_READ_FREQUENCY 20000000
#définir SPI_TOUCH_FREQUENCY 2500000 //2500000
// Ce sketch sert à tester le contrôleur tactile, rien n'est affiché
// sur le TFT. La bibliothèque TFT_eSPI doit être configurée en fonction de votre
// broches utilisées. Assurez-vous que la puce tactile est sélectionnée et la puce TFT
// select sont correctement définis pour éviter les conflits de bus SPI.
// Assurez-vous d'avoir défini une broche pour la puce du contrôleur tactile
// sélectionnez la ligne dans le fichier de configuration utilisateur ou vous verrez "aucun membre"
// compile les erreurs pour les fonctions tactiles !
// Il s'agit d'une esquisse de support et de diagnostic pour la bibliothèque TFT_eSPI :
// https://github.com/Bodmer/TFT_eSPI
// Les sorties "brutes" (non traitées) du capteur tactile sont envoyées au
// port série. Toucher l'écran devrait afficher les modifications apportées aux x, y
// et z valeurs. x et y sont des lectures ADC brutes, pas des coordonnées de pixels.
#include <SPI.h>
#include <TFT_eSPI.h>
TFT_eSPI tft = TFT_eSPI();
//================================================= ====================
configuration vide (vide) {
Série.begin(115200);
Serial.println("\n\nDémarrage...");
tft.init();
}
//================================================= ====================
boucle vide() {
uint16_t x, y ;
tft.getTouchRaw(&x, &y);
Serial.printf("x: %i ", x);
Serial.printf("y: %i ", y);
Serial.printf("z: %i \n", tft.getTouchRawZ());
retard (250);
}
//================================================= ====================
J’ai trouvé un autre article indiquant que l’ESP32-3248S035 utilise un GT911 pour l’écran tactile capacitif.
Avec la bibliothèque TAMC_GT911 de TAMC dans V : 1.0.2, je l’ai fait fonctionner avec son exemple et j’ai ajusté le brochage pour :
#define TOUCH_SDA 33
#define TOUCH_SCL 32
#définir TOUCH_INT 21
#définir TOUCH_RST 25
#define TOUCH_WIDTH 320
#définir TOUCH_HEIGHT 480