Skip to content

Display

The capacitive Nextion display is what makes the NSPanel a good Home automation product.

GPIO

In the original board the nextion display communicates with the esp32 via IO16 & IO17. In the new board the display communicates with the esp32 via IO5 & IO6, they are not hardware UART but that was already allocated to the presence sensor which has a higher baudrate.

Configuration

Always refer to the esphome folder for the most up to date working configuration. This is a known to be working minimal configuration for the display

uart:
  - tx_pin: 5
    rx_pin: 6
    baud_rate: 115200
    rx_buffer_size: 4096
    id: tf_uart

display:
  - platform: nextion
    id: disp1
    uart_id: tf_uart
    tft_url: $tft_url

switch:
  - platform: gpio
    name: Screen Power
    id: screen_power
    entity_category: config
    pin:
      number: 4
      inverted: true
    restore_mode: ALWAYS_OFF

Please note that the tft_url should be the path to the compiled tft file. The tft file is the compiled version of the HMI file that is generated by the Nextion Editor.

Also note that there are other configuration elements that make the display work as expected. Please refer to the esphome folder for the most up to date configuration.

Part

There are several parts that are required for the display to work. The parts are all contained in the DISPLAY silkscreen polygon.

Display Firmware

The nextion display can be updated via the UART interface. The display firmware is included in this repository. With the original NSPanel hardware, uploading a new tft file to the display was a pain. With the new board, thanks to the more generous availability of memory, uploading a new tft file is a breeze.

The firmware for the display is included in this repository and can be found in the nextion folder. Wish you modify the display firmware, you can use the Nextion Editor generate the HMI file (or modify the provided one) and then compile it to a tft file.

Getting ready to flash the display firmware

To flash the display firmware you need to have the following:

  • a working http server that can serve the tft file
  • a working esphome firmware that can communicate with the display
  • a HomeAssistant service that can trigger the display firmware update

1) The webserver

as of the http server I suggest you to spin up a simple nginx server that serves the tft file.

The following Nginx configuration should work:

server {
    listen 80;
    root /var/www/html;
}
Just place the tft file in the /var/www/html folder and you should be good to go.

Also, using something like filebrowser should make the process easier to manage firmware files.

2) The esphome firmware

The esphome configuration is provided in the esphome/nextion.yaml file.

To summarize you need to have at least the uart, the display and the api component for the next step

3) The HomeAssistant service

The HomeAssistant service is provided in the esphome/nextion.yaml file.

But you can also use the following service:

api:
  services:
    - service: upload_tft
      then:
        - lambda: 'id(disp1)->upload_tft();'

The $tft_url should be provided as part of the yaml esphome configuration. (check esphome/vekexasia-hmi.yaml for an example)