Esphome & nextion tft lcd

I too have been trying to get my nextion display to work with ESPHome but it’s just not working anymore. At first I was able to get the nextion to communicate but it had these frequent errors in the logs about filler bits, then it just crapped out. Been spending a week tryin to figure it all out but I’m thinking i’m gonna scrap it and look into cameron’s suggestion and try out that second link he shared.

1 Like

Looks like this is a project I need to get working and create a howto.

Famous last words :slight_smile:

1 Like

Nice one @nickrout looking forward to seeing your project. :sweat_smile:

1 Like

Ok, got it working. To receive the nextion codes in homeassistant the page id and button id need to match and above that the “send component ID” on touch press event and touch release event need to be “checked”.

binary_sensor:
  - platform: nextion
    page_id: 0
    component_id: 3
    name: "Nextion.Button.Doorbel"
  - platform: nextion
    page_id: 1
    component_id: 2
    name: "Nextion.Button.Package delivered"

Also on "uploading the compiled file from the nextion editor you need to do via SD card you must use “file - TFT file output” and put that file on SD card, boot display, remove SD card reboot display…

and be sure RX is connected to TX and vice versa.

One burning remaining question:

How can I send such a TFT file via ESPhome!? I do want to be able to change the layout of the display later on without opening a steady mounting case to hassle with an SD card… possible?

2 Likes

That’s great now get the buttons to get feedback from HA . :thinking:

What do you mean?

So I am pretty far now… have a display working with buttons, states in HA, nodered connected with telegram. pressing a touch button direct message etc.

1 thing can’t get working…
I can do a multiple line in nextion editor:

I can send a new value via:

display:
  - platform: nextion
    lambda: |-
      it.set_wait_for_ack(false);
      it.set_component_text("t10", id(t10_text).state.c_str());
      
text_sensor:
  - platform: homeassistant
    id: t10_text
    entity_id: sensor.nextion_text1

but that value, if longer than 1 sentence is not divided over multiple lines, it just shows “off-screen”:

Any thoughts on how to “divide” over mutliple lines?

This suggests that it can’t be done https://forum.arduino.cc/index.php?topic=604185.15

But of course that was just the first thing google found, so the answer is I am still not sure.

ok, can be done. in the editor need to set “isbr” to true.

1 Like

Question is now black (burned) :slight_smile:

Dear People, I have a problem with my esphome configuration with an nextion display. Actually I have it completely working, only I get an annoying message. I use a number of sensors that I want to show on page 3. Now I have the config so that this also happens. But if I am now on a different page then I get a warning (yellow) in my log from my esphome (see attachment). I expect to somehow have to point my sensors to page3 but I just don’t know how to do this. i hope you can help me with this.

CODE ESPHOME
uart:
rx_pin: D9
tx_pin: D10
baud_rate: 9600

display:

  • platform: nextion
    update_interval: 1s
    lambda: |-
    it.set_wait_for_ack(false);

                auto time_text = id(sntp_time).now().strftime("%X");
                it.set_component_text("text_time", time_text.c_str());
                auto date_text = id(sntp_time).now().strftime("%x");
                it.set_component_text("text_date", date_text.c_str());
                auto week_text = id(sntp_time).now().strftime("%W");
                it.set_component_text("weeknr", week_text.c_str());          
                auto time = id(sntp_time).now();
    
    
             it.set_component_text_printf("hour","%02d",time.hour);
             it.set_component_text_printf("minut","%02d",time.minute);     
             it.set_component_text_printf("outside","%2.1f", id(temp).state);
             it.set_component_text_printf("vocht","%2.1f", id(vocht).state);
             it.set_component_text_printf("rain","%2.1f", id(rain).state);       
             it.set_component_text_printf("lux","%2.1f", id(lux).state);
             it.set_component_text_printf("luxin","%2.1f", id(lux_woonkamer).state);
             it.set_component_text_printf("vochtin","%2.1f", id(hum_woonkamer).state);
             it.set_component_text_printf("inside","%2.1f", id(temp_woonkamer).state);  
    

time:

  • platform: sntp
    id: sntp_time

sensor:

  • platform: homeassistant
    id: temp
    entity_id: sensor.sensor_box_am2301_13_temperature

  • platform: homeassistant
    id: vocht
    entity_id: sensor.sensor_box_am2301_13_humidity

  • platform: homeassistant
    id: rain
    entity_id: sensor.tfa_80_0c_rain_total

  • platform: homeassistant
    id: lux
    entity_id: sensor.sensor_box_bh1750_illuminance

  • platform: wifi_signal
    name: “WiFi signal HMI”
    update_interval: 60s

  • platform: hdc1080
    temperature:
    name: “Temp_woonkamer”
    id: temp_woonkamer
    humidity:
    name: “Humidity_woonkamer”
    id: hum_woonkamer
    update_interval: 5s

  • platform: bh1750
    id: lux_woonkamer
    name: “BH1750_lux_woonkamer”
    address: 0x23
    measurement_time: 69
    update_interval: 5s

i2c:
sda: D2
scl: D1
scan: False

binary_sensor:

  • platform: nextion
    page_id: 1
    component_id: 3
    name: “hmi_rolluik_keuken_omhoog”

  • platform: nextion
    page_id: 1
    component_id: 6
    name: “hmi_rolluik_keuken_omlaag”

  • platform: nextion
    page_id: 1
    component_id: 4
    name: “hmi_rolluik_straat_omhoog”

  • platform: nextion
    page_id: 1
    component_id: 8
    name: “hmi_rolluik_straat_omlaag”

  • platform: nextion
    page_id: 1
    component_id: 5
    name: “hmi_voordeur_omhoog”

  • platform: nextion
    page_id: 1
    component_id: 7
    name: “hmi_voordeur_omlaag”

  • platform: nextion
    page_id: 4
    component_id: 3
    name: “100%nl”

  • platform: nextion
    page_id: 4
    component_id: 5
    name: “Qmusic”

  • platform: nextion
    page_id: 4
    component_id: 6
    name: “538”

  • platform: nextion
    page_id: 4
    component_id: 4
    name: “woonkamer_speaker_uit”

  • platform: nextion
    page_id: 4
    component_id: 10
    name: “volume_12”

  • platform: nextion
    page_id: 4
    component_id: 9
    name: “volume_14”

  • platform: nextion
    page_id: 4
    component_id: 8
    name: “volume_16”

  • platform: nextion
    page_id: 4
    component_id: 7
    name: “volume_18”

switch:

  • platform: restart
    name: “Reset HMI”

  • platform: shutdown
    name: “Uitschakelen HMI”

output:

  • platform: esp8266_pwm
    pin: D8
    id: pwm_output

light:

  • platform: monochromatic
    output: pwm_output
    name: “buzzer”

WARNINGS
[23:58:09][D][nextion:209]: Got touch page=3 component=1 type=PRESS
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!
[23:58:10][W][nextion:177]: Nextion reported variable name invalid!

Please format all your code correctly.

What do you mean ?

Hi!
I’m trying to display the state of the binary sensor ON and OFF, I can’t display it on the screen, I’ve tried various options but unsuccessfully.

sensor:
  - platform: homeassistant   # Kitchen window
    id: win_kitchen
    entity_id: sensor.window_kitchen

and

display:
  - platform: nextion
    id: teplomer
    update_interval: 5s
    lambda: |-
               it.set_component_text_printf("winkitchen","%",id(win_kitchen).state);

I try %s (String of characters) but nothing. How to print binary state of sensor?
Log of esphome [00:15:32][W][homeassistant.sensor:014]: Can’t convert ‘ON’ to number!

P.S. It is work i understand

text_sensor:
  - platform: homeassistant   # Kitchen window
    id: win_kitchen
    entity_id: sensor.window_kitchen

and 
   it.set_component_text_printf("winkitch","%s",id(win_kitchen).state.c_str());            

I try to get mine to work but I got error from the esphome log screen “received unknown filler end bytes from Nextion!”. What did I do wrong? I check all the examples but unable to get it to work with esphome.

On the esphome long it showed message of “Sending command ‘t0.txt=Hellooo’ failed because no ACK was received … : Waiting for ACK timed out!” but nothing on the display. I flip the tx and rx but still same result.

I’m plugging my nextion PR for esphome.

It has a ton of improvements, including tft Ota. We are working hard on getting this merged.

7 Likes

Been following what your are doing and thanks for that.
Will the documentation also be updated?

There is a PR for it and will be updated once we get closer to merging. I actually am planning on updating it soon though.

2 Likes