UPDATE: This morning I looked at the underside of the display PCB and it’s says “480x320” not 310x240.
Get_width and get_height appear to return 320x240 as shown in the log below.
I have updated the title of the thread accordingly
OP:
Hi All, I bought one of these displays (the 4" version) from Ali Express and am trying to get it working with ESPHome 2022.9.4 which in turn is being used to flash an ESP32 device.
The black area should occupy the whole of the screen area the border should be blue and heaven knows why I have got noise on the right of the screen.
In the logs for the device I can see the screen size being detected correctly (see below). After the log file I have included the yaml for the esphome project. Any idea what I am doing wrong? Rotating the screen (in the yaml) doesn’t seem to make any difference and from searching I’m not the only one with this issue.
Thanks to anyone who can give me some clues on where to start fixing it.
[19:20:31][C][wifi:365]: Hostname: ‘esp32-hd2-display’
[19:20:31][C][wifi:367]: Signal strength: -54 dB ▂▄▆█
[19:20:31][C][wifi:371]: Channel: 3
[19:20:31][C][wifi:372]: Subnet: 255.255.255.0
[19:20:31][C][wifi:373]: Gateway: 192.168.0.1
[19:20:31][C][wifi:374]: DNS1: 192.168.0.1
[19:20:31][C][wifi:375]: DNS2: 0.0.0.0
[19:20:31][C][logger:275]: Logger:
[19:20:31][C][logger:276]: Level: DEBUG
[19:20:31][C][logger:277]: Log Baud Rate: 115200
[19:20:31][C][logger:278]: Hardware UART: UART0
[19:20:31][C][spi:101]: SPI bus:
[19:20:31][C][spi:102]: CLK Pin: GPIO18
[19:20:31][C][spi:103]: MISO Pin: GPIO19
[19:20:31][C][spi:104]: MOSI Pin: GPIO23
[19:20:31][C][spi:106]: Using HW SPI: YES
[19:20:31][C][ili9341:029]: ili9341
[19:20:31][C][ili9341:029]: Rotations: 0 °
[19:20:31][C][ili9341:029]: Dimensions: 240px x 320px
[19:20:31][C][ili9341:030]: Reset Pin: GPIO17
[19:20:31][C][ili9341:031]: DC Pin: GPIO27
[19:20:31][C][ili9341:033]: Update Interval: 1.0s
[19:20:31][C][homeassistant.time:010]: Home Assistant Time:
[19:20:31][C][homeassistant.time:011]: Timezone: ‘GMT0BST,M3.5.0/1,M10.5.0’
[19:20:31][C][captive_portal:088]: Captive Portal:
[19:20:31][C][mdns:100]: mDNS:
[19:20:31][C][mdns:101]: Hostname: esp32-hd2-display
[19:20:31][C][ota:089]: Over-The-Air Updates:
[19:20:31][C][ota:090]: Address: esp32-hd2-display.local:3232
[19:20:31][C][ota:093]: Using Password.
[19:20:31][C][api:138]: API Server:
[19:20:31][C][api:139]: Address: esp32-hd2-display.local:6053
[19:20:31][C][api:141]: Using noise encryption: YES
YAML:
esphome:
name: "esp32-hd2-display"
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
time:
- platform: homeassistant
id: esptime
color:
- id: my_red
red: 100%
green: 0%
blue: 0%
- id: my_yellow
red: 100%
green: 100%
blue: 0%
- id: my_green
red: 0%
green: 100%
blue: 0%
- id: my_blue
red: 0%
green: 0%
blue: 100%
- id: my_gray
red: 50%
green: 50%
blue: 50%
font:
- file: "arial.ttf"
id: arial_48
size: 48
- file: "arial.ttf"
id: arial_36
size: 36
- file: "arial.ttf"
id: arial_24
size: 24
- file: "arial.ttf"
id: arial_12
size: 12
- file: "arial.ttf"
id: arialbd_font
size: 12
globals:
- id: enable_change
type: bool
restore_value: no
initial_value: 'true'
spi:
clk_pin: GPIO18
mosi_pin: GPIO23
miso_pin: GPIO19
#output:
# - platform: ledc
# pin: 32
# id: gpio_32_backlight_pwm
display:
- platform: ili9341
model: TFT 2.4
cs_pin: GPIO5
dc_pin: GPIO27
reset_pin: GPIO17
auto_clear_enabled: True
update_interval: 1s
id: my_display
led_pin: GPIO32
rotation: 0
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue));
it.rectangle(0, 20, it.get_width(), it.get_height(), id(my_blue));
it.strftime((240 / 2), (140 / 3) * 1 + 5, id(arial_24), id(my_gray), TextAlign::CENTER, "%Y-%m-%d", id(esptime).now());
it.strftime((240 / 2), (140 / 3) * 2 + 5, id(arial_48), id(my_gray), TextAlign::CENTER, "%H:%M:%S", id(esptime).now());
it.print(5, 5, id(arial_12), id(my_yellow), TextAlign::TOP_LEFT, "ESPHome");
# Enable Home Assistant API