masto / NSPanel-Demo-Files

Sample files to go with https://youtu.be/Kdf6W_Ied4o
https://youtu.be/Kdf6W_Ied4o
MIT License
104 stars 23 forks source link

TFT demo file issues, baud rate #7

Open zackpollard opened 1 year ago

zackpollard commented 1 year ago

Hey, firstly thanks for the video, really helped with getting this thing flashed with ESPHome. During this process however, I found an issue with the demo TFT files. In Nextion you need to set the baud rate in the Project.s settings to bauds=115200. Without this, after flashing your demo TFT onto the NSPanel, ESPHome can no longer connect to the Nextion display as your ESPHome config tries to communicate at 115200, but the default Nextion rate is 9600. This took me a long while to figure out, and in the process I think I found a few other people who have posted about this same problem around the internet but gave up.

Steps to fix:

  1. Set baud rate in ESPHome config to 9600.
  2. Transfer a blank TFT to the display with bauds=115200 in the Project.s config file. (blank to reduce size, takes a long time at 9600 baud rate)
  3. Set ESPHome config back to 115200 baud rate
  4. Flash your new Nextion TFT file, ensuring bauds=115200 is in the Project.s config, or you'll have to repeat this process again.

Hopefully even if this doesn't get fixed in the demo files, this will help out some other people who stumble across this same problem.

masto commented 1 year ago

Thanks for the note and for diagnosing the issue. I wonder if there was some external change that triggered this problem, since I haven't run into it. Though realistically, once I got my panels working, I haven't done any more with them.

I'm not sure if/when I'll have the time to dive back into this, so if you want to send a PR I'll merge it. Or you can add a note to the Wiki.

Horse2370 commented 1 month ago

I'll add another issue resolution if you want to add it the wiki. Using the later 2024.4.2 ESPHome I had issues getting the display to connect and to upload due to reparse mode being enabled.

Changes to the yaml file to make it work. set the logger baud_rate to 0 and also had to power off and on the NS Panel to get the display to connect. in the logs you will see the following if it connects successfully and Exit reparse YES if you use the command below. After that it updates the Nextion screen quickly.

Nextion:
[01:09:22][C][nextion:129]:   Device Model:     NX4832F035_011C
[01:09:22][C][nextion:130]:   Firmware Version: 48
[01:09:22][C][nextion:131]:   Serial Number:    1234567890
[01:09:22][C][nextion:132]:   Flash Size:       16777216
[01:09:22][C][nextion:133]:   Wake On Touch:    YES
[01:09:22][C][nextion:134]:   Exit reparse:     YES
logger:
  id: logger_std
  baud_rate: 0

Needed to exit reparse mode after the display connected, so the tft file upload would work. This is possible via the display config.

display:
  - platform: nextion
    id: disp1
    uart_id: tf_uart
    exit_reparse_on_start: true
    tft_url: http://yourwwwserver/nspanel_demo.tft

Configured one of the physical buttons to trigger the tft upload

binary_sensor:
  - platform: gpio
    name: $device_name Left Button
    pin:
      number: 14
      inverted: true
    on_click:
      - lambda: 'id(disp1)->upload_tft();'