ESPHome Nextion Update fail

Hi all,

I have following problem: I have a Nextion NX4827T043_011R Screen.
If I wont do update/upload the tft file to the screen, it fail.

I tried with baud_rate 9600 and 115200. in the tft file I have also bauds=9600 or bauds=115200

esphome:
  name: haier3
  friendly_name: Haier3

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
  #level: VERY_VERBOSE
# Enable Home Assistant API
api:
  encryption:
    key: !secret api_key

ota:
  - platform: esphome
    password: !secret ota_password

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0
  power_pin: GPIO12
  manual_ip:
    static_ip: xxx.xxx.xxx.xxx
    gateway: xxx.xxx.xxx.xxx
    subnet: 255.255.255.240
# A reboot button is always useful
button:
  - platform: restart
    name: Restart

  # A button for the TFT upload
  - platform: template
    name: Update TFT
    device_class: update
    on_press:
      then:
        - lambda: 'id(nextion1)->upload_tft();'
uart:
  tx_pin: GPIO32 #GPIO4
  rx_pin: GPIO33 #GPIO36
  baud_rate: 9600
  id: uart_nextion


display:
  - platform: nextion
    id: nextion1
    uart_id: uart_nextion
    tft_url: http://xxx.xxx.xxx.xxx:8123/local/tft/climate.tft
    on_touch:
      - lambda: |-
          ESP_LOGD("nextion.on_touch", "Nextion touch event detected!");
          ESP_LOGD("nextion.on_touch", "Page Id: %i", page_id);
          ESP_LOGD("nextion.on_touch", "Component Id: %i", component_id);
          ESP_LOGD("nextion.on_touch", "Event type: %s", touch_event ? "Press" : "Release");
      - lambda: |-
          char ontouch_json[128];
          sprintf(ontouch_json, "{\"page_id\": %i, \"component_id\": %i, \"event_type\": %i}", page_id, component_id, touch_event);
          nextion_touch_event->publish_state(ontouch_json);
    update_interval: 1s
    lambda: |-
      it.set_component_value("gauge", 50);
      it.set_component_text("textview", "Hello World!"); 


time:
  - platform: sntp
    id: sntp_time

    

binary_sensor:
  - platform: status
    name: "${upper_devicename} Status"


text_sensor:
# Reports the ESPHome Version with compile date
  - platform: version
    name: ${upper_devicename} ESPHome Version
  - id: nextion_touch_event
    name: Nextion Touch Event
    platform: template
    update_interval: never
    internal: false

Log:

INFO Successfully connected to haier3 @ xxx.xxx.xxx.xxx in 0.001s
INFO Successful handshake with haier3 @ xxx.xxx.xxx.xxx in 0.133s
[10:31:55][D][nextion:302]: Manually set nextion report ready
[10:31:55][D][nextion:380]: Nextion is setup
[10:31:55][E][nextion:311]: Nextion queue is empty!
[10:31:59][D][button:010]: 'Update TFT' Pressed.
[10:31:59][D][nextion.upload.arduino:154]: Nextion TFT upload requested
[10:31:59][D][nextion.upload.arduino:155]: Exit reparse: YES
[10:31:59][D][nextion.upload.arduino:156]: URL: http://xxx.xxx.xxx.43:8123/local/tft/climate.tft
[10:31:59][D][nextion.upload.arduino:171]: Exiting Nextion reparse mode
[10:31:59][D][nextion.upload.arduino:185]: Baud rate: 9600
[10:31:59][D][nextion.upload.arduino:213]: Connected
[10:31:59][D][nextion.upload.arduino:218]: Requesting URL: http://xxx.xxx.xxx.43:8123/local/tft/climate.tft
[10:31:59][D][nextion.upload.arduino:244]: TFT file size: 339284 bytes
[10:31:59][D][nextion.upload.arduino:256]: Uploading Nextion
[10:32:00][D][nextion.upload.arduino:297]: Upgrade response is [05] - 1 byte(s)
[10:32:00][D][nextion.upload.arduino:310]: Uploading TFT to Nextion:
[10:32:00][D][nextion.upload.arduino:311]:   URL: http://xxx.xxx.xxx.43:8123/local/tft/climate.tft
[10:32:00][D][nextion.upload.arduino:312]:   File size: 339284 bytes
[10:32:00][D][nextion.upload.arduino:313]:   Free heap: 255028
[10:32:00][D][nextion.upload.arduino:036]: Range start: 0
[10:32:05][D][nextion.upload.arduino:107]: Uploaded 1.21%, remaining 335188 bytes, free heap: 252500 bytes
WARNING haier3 @ xxx.xxx.xxx.xxx: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for haier3 @ xxx.xxx.xxx.xxx
WARNING Disconnected from API
INFO Successfully connected to haier3 @ xxx.xxx.xxx.xxx in 0.005s
INFO Successful handshake with haier3 @ xxx.xxx.xxx.xxx in 0.125s
[10:32:30][W][nextion:091]: Nextion is not connected! 
[10:32:30][W][nextion:091]: Nextion is not connected! 
[10:32:31][W][nextion:091]: Nextion is not connected! 
[10:32:31][W][nextion:091]: Nextion is not connected! 
[10:32:32][W][nextion:091]: Nextion is not connected! 

And on the screen:

What I’m doing wrong?

Thanks for the help.
Adrian

Hi,
Did you solve the problem by any chance? I have the same error message with Wemos D1 Mini

Same here, I’m trying to connect an ESP32 c3 devkitm to a nextion 7" display. Both on minimal config, baud set to 9600, checked pins several times, rx and tx are crossed, added the sendme command as well in the Nextion editor, rebooted multiple times, and most important, I’m out of ideas. ESP32 reports ‘Nextion not connected’.

Sadly no…

How do you connect the Nextion to the ESPHome? I had the USB interface board between the display and the EPS32, when I connected ESP32 direct to the Nextion is strated to work.

I had it only connected to the esp32.
What code did you use?

Here’s the Uart part, I guess an important part. To make mine succesfull, I used ChatGPT a lot. I’m not a coder, but with ChatGPT it all works perfectly, with a retry here and there :wink:

uart:
  id: uart_nextion
  tx_pin: 7
  rx_pin: 6
  baud_rate: 9600
  debug:
    direction: BOTH
    after:
      delimiter: [0xFF, 0xFF, 0xFF]  # Nextion terminator
      timeout: 50ms
    sequence:
      - lambda: |-
          std::string data(bytes.begin(), bytes.end());
          if (data.find("touch") != std::string::npos) {
            id(screensaver_timer) = 0;