esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

Nextion display won´t sleep #5320

Open Hellfish78 opened 9 months ago

Hellfish78 commented 9 months ago

The problem

Auto sleep and wake on touch is enabled but the nextion display (nspanel) won´t go into sleep mode. I´ve set thsp=30 thup=1 as preinitialze event in nextion editor. Within the nextion debugger it works as intended and the display sleeps after 30 seconds.

Which version of ESPHome has the issue?

2023.12.5

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2023.12.4

What platform are you using?

ESP32

Board

sonoff nspanel

Component causing the issue

No response

Example YAML snippet

esphome:
  name: nspanel
  comment: $device_name
esp32:
  board: esp32dev

substitutions:
 device_name: nspanel
 wifi_ssid: !secret wifi_ssid
 wifi_pass: !secret wifi_password
 tft_url: !secret tft_upload_url

#web_server:
#  port: 80
#  css_url: ""
#  js_url: https://esphome.io/_static/v2/www.js
#  version: 2

# Configure the screen itself
display:
- platform: nextion
  id: disp1
  uart_id: tf_uart
  tft_url: $tft_url
  touch_sleep_timeout: 30
  auto_wake_on_touch: True

# Uart for the Nextion display
uart:
  tx_pin: 16
  rx_pin: 17
  baud_rate: 115200 # has to be set at program.s on the nextion editor 
  id: tf_uart

# i2c bus configuration
i2c:
  sda: 19
  scl: 22
  scan: true
  id: bus_a

# setting up the i2c adress for external adc modul
ads1115:
  - address: 0x48

# Wifi settings
wifi:
  ssid: $wifi_ssid
  password: $wifi_pass
# enable the fallback hotspot
  ap:
    ssid: "fallback"
    password: ""

# enable the ota update
ota:
  password: !secret ota_password

# enable the captive portal
captive_portal:

# enable the serial logger
logger:

# haas api
api:
  services:          
      # Service to update the nextion tft file
        - service: upload_tft
          then:
          - lambda: 'id(disp1)->upload_tft();'

sensor:
  # Internal temperature sensor, adc value
  - platform: adc
    id: ntc_source
    pin: 38
    update_interval: 300s
    attenuation: 11db

  # Internal temperature sensor, adc reading converted to resistance (calculation) 
  - platform: resistance
    id: resistance_sensor
    sensor: ntc_source
    configuration: DOWNSTREAM
    resistor: 11.2kOhm

  # Internal temperature sensor, resistance to temperature (calculation)
  - platform: ntc
    id: temperature
    sensor: resistance_sensor
    calibration:
      b_constant: 3950
      reference_temperature: 25°C
      reference_resistance: 10kOhm
    name: $device_name Temperature

  # external adc sensors by ADS1115
  - platform: ads1115
    multiplexer: 'A0_GND'
    id: A0_GND
    gain: 4.096
    unit_of_measurement: ""
    update_interval: 300s
    name: "ADS1115 Channel A0-GND"
    filters:
      - calibrate_linear:
          - 0.000 -> 0.000
          - 2.200 -> 100
      - clamp:
          min_value: 0
          max_value: 100
    on_value:
# output to nextion display
      then:
      - lambda: id(disp1).set_component_value("page0.j0",id(A0_GND).state);

  - platform: ads1115
    multiplexer: 'A1_GND'
    id: A1_GND
    gain: 4.096
    unit_of_measurement: ""
    update_interval: 300s
    name: "ADS1115 Channel A1-GND"
    filters:
      - calibrate_linear:
          - 0.000 -> 0.000
          - 2.200 -> 100
      - clamp:
          min_value: 0
          max_value: 100
    on_value:
# output to nextion display
      then:
      - lambda: id(disp1).set_component_value("page0.j1",id(A1_GND).state);

#  - platform: ads1115
#    multiplexer: 'A2_GND'
#    gain: 4.096
#    update_interval: 10s
#    name: "ADS1115 Channel A2-GND"

#  - platform: ads1115
#    multiplexer: 'A3_GND'
#    gain: 4.096
#    update_interval: 10s
#    name: "ADS1115 Channel A3-GND"

switch:
  # Pin 4 always needs to be on to power up the display
  - platform: gpio
    id: screen_power
    entity_category: config
    pin:
      number: 4
      inverted: true
    restore_mode: ALWAYS_ON

  - platform: gpio
    name: $device_name Relay 1
    id: relay_1
    pin: 23
    restore_mode: ALWAYS_OFF

# integrated switch buttons
binary_sensor:
  - platform: gpio
    name: $device_name Left Button
    pin:
      number: 14
      inverted: true

  - platform: gpio
    name: $device_name Right Button
    pin:
      number: 27
      inverted: true

Anything in the logs that might be useful for us?

INFO ESPHome 2023.12.5
INFO Reading configuration /config/esphome/nspanel.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing nspanel (board: esp32dev; framework: arduino; platform: platformio/espressif32@5.4.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.0.1
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.1.0
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- Wire @ 2.0.0
|-- WiFiClientSecure @ 2.0.0
|-- HTTPClient @ 2.0.0
Compiling .pioenvs/nspanel/src/main.cpp.o
Linking .pioenvs/nspanel/firmware.elf
RAM:   [=         ]  13.2% (used 43248 bytes from 327680 bytes)
Flash: [======    ]  58.3% (used 1070613 bytes from 1835008 bytes)
Building .pioenvs/nspanel/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs/nspanel/firmware.bin"], [".pioenvs/nspanel/firmware.elf"])
Wrote 0x116ca0 bytes to file /data/build/nspanel/.pioenvs/nspanel/firmware-factory.bin, ready to flash to offset 0x0
========================= [SUCCESS] Took 6.96 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.178.151
INFO Uploading /data/build/nspanel/.pioenvs/nspanel/firmware.bin (1076384 bytes)
Uploading: [============================================================] 100% Done...

INFO Upload took 8.89 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.178.151 using esphome API
INFO Successfully connected to nspanel @ 192.168.178.151 in 15.322s
INFO Successful handshake with nspanel @ 192.168.178.151 in 0.021s
[09:08:58][I][app:102]: ESPHome version 2023.12.5 compiled on Dec 31 2023, 09:08:25
[09:08:58][C][wifi:573]: WiFi:
[09:08:58][C][wifi:414]:   Hostname: 'nspanel'
[09:08:58][C][wifi:416]:   Signal strength: -36 dB ▂▄▆█
[09:08:58][C][wifi:420]:   Channel: 11
[09:08:58][C][wifi:421]:   Subnet: 255.255.255.0
[09:08:58][C][wifi:422]:   Gateway: 192.168.178.1
[09:08:58][C][wifi:423]:   DNS1: 192.168.178.1
[09:08:58][C][wifi:424]:   DNS2: 0.0.0.0
[09:08:58][C][logger:443]: Logger:
[09:08:58][C][logger:444]:   Level: DEBUG
[09:08:58][C][logger:445]:   Log Baud Rate: 115200
[09:08:58][C][logger:447]:   Hardware UART: UART0
[09:08:58][C][i2c.arduino:053]: I2C Bus:
[09:08:58][C][i2c.arduino:054]:   SDA Pin: GPIO19
[09:08:58][C][i2c.arduino:055]:   SCL Pin: GPIO22
[09:08:58][C][i2c.arduino:056]:   Frequency: 50000 Hz
[09:08:58][C][i2c.arduino:059]:   Recovery: bus successfully recovered
[09:08:58][I][i2c.arduino:069]: Results from i2c bus scan:
[09:08:58][I][i2c.arduino:075]: Found i2c device at address 0x48
[09:08:58][C][uart.arduino_esp32:137]: UART Bus 1:
[09:08:58][C][uart.arduino_esp32:138]:   TX Pin: GPIO16
[09:08:58][C][uart.arduino_esp32:139]:   RX Pin: GPIO17
[09:08:58][C][uart.arduino_esp32:141]:   RX Buffer Size: 256
[09:08:58][C][uart.arduino_esp32:143]:   Baud Rate: 115200 baud
[09:08:58][C][uart.arduino_esp32:144]:   Data Bits: 8
[09:08:58][C][uart.arduino_esp32:145]:   Parity: NONE
[09:08:58][C][uart.arduino_esp32:146]:   Stop bits: 1
[09:08:58][C][switch.gpio:068]: GPIO Switch 'screen_power'
[09:08:58][C][switch.gpio:091]:   Restore Mode: always ON
[09:08:58][C][switch.gpio:031]:   Pin: GPIO4
[09:08:58][C][switch.gpio:068]: GPIO Switch 'nspanel Relay 1'
[09:08:58][C][switch.gpio:091]:   Restore Mode: always OFF
[09:08:58][C][switch.gpio:031]:   Pin: GPIO23
[09:08:58][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'nspanel Left Button'
[09:08:58][C][gpio.binary_sensor:016]:   Pin: GPIO14
[09:08:58][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'nspanel Right Button'
[09:08:58][C][gpio.binary_sensor:016]:   Pin: GPIO27
[09:08:58][C][ads1115:073]: Setting up ADS1115...
[09:08:58][C][ads1115:074]:   Address: 0x48
[09:08:58][C][ads1115:080]:   Sensor 'ADS1115 Channel A0-GND'
[09:08:58][C][ads1115:080]:     Device Class: 'voltage'
[09:08:58][C][ads1115:080]:     State Class: 'measurement'
[09:08:58][C][ads1115:080]:     Unit of Measurement: ''
[09:08:58][C][ads1115:080]:     Accuracy Decimals: 3
[09:08:58][C][ads1115:081]:     Multiplexer: 4
[09:08:58][C][ads1115:082]:     Gain: 1
[09:08:58][C][ads1115:083]:     Resolution: 16
[09:08:58][C][ads1115:080]:   Sensor 'ADS1115 Channel A1-GND'
[09:08:58][C][ads1115:080]:     Device Class: 'voltage'
[09:08:58][C][ads1115:080]:     State Class: 'measurement'
[09:08:58][C][ads1115:080]:     Unit of Measurement: ''
[09:08:58][C][ads1115:080]:     Accuracy Decimals: 3
[09:08:58][C][ads1115:081]:     Multiplexer: 5
[09:08:58][C][ads1115:082]:     Gain: 1
[09:08:58][C][ads1115:083]:     Resolution: 16
[09:08:58][C][adc:097]: ADC Sensor 'ntc_source'
[09:08:58][C][adc:097]:   Device Class: 'voltage'
[09:08:58][C][adc:097]:   State Class: 'measurement'
[09:08:58][C][adc:097]:   Unit of Measurement: 'V'
[09:08:58][C][adc:097]:   Accuracy Decimals: 2
[09:08:58][C][adc:107]:   Pin: GPIO38
[09:08:58][C][adc:122]:  Attenuation: 11db
[09:08:58][C][adc:142]:   Update Interval: 300.0s
[09:08:58][C][resistance:010]: Resistance Sensor 'resistance_sensor'
[09:08:58][C][resistance:010]:   State Class: 'measurement'
[09:08:58][C][resistance:010]:   Unit of Measurement: 'Ω'
[09:08:58][C][resistance:010]:   Accuracy Decimals: 1
[09:08:58][C][resistance:010]:   Icon: 'mdi:flash'
[09:08:58][C][resistance:011]:   Configuration: DOWNSTREAM
[09:08:58][C][resistance:012]:   Resistor: 11200.00Ω
[09:08:58][C][resistance:013]:   Reference Voltage: 3.3V
[09:08:58][C][ntc:014]: NTC Sensor 'nspanel Temperature'
[09:08:58][C][ntc:014]:   Device Class: 'temperature'
[09:08:58][C][ntc:014]:   State Class: 'measurement'
[09:08:58][C][ntc:014]:   Unit of Measurement: '°C'
[09:08:58][C][ntc:014]:   Accuracy Decimals: 1
[09:08:58][C][nextion:128]: Nextion:
[09:08:58][C][nextion:129]:   Device Model:     NX4832F035_011C
[09:08:58][C][nextion:130]:   Firmware Version: 72
[09:08:58][C][nextion:131]:   Serial Number:    B8B034015C9DFF53
[09:08:58][C][nextion:132]:   Flash Size:       16777216
[09:08:58][C][nextion:133]:   Wake On Touch:    YES
[09:08:58][C][nextion:134]:   Exit reparse:     NO
[09:08:58][C][nextion:137]:   Touch Timeout:    30
[09:08:58][C][captive_portal:088]: Captive Portal:
[09:08:58][C][mdns:115]: mDNS:
[09:08:58][C][mdns:116]:   Hostname: nspanel
[09:08:58][C][ota:097]: Over-The-Air Updates:
[09:08:58][C][ota:098]:   Address: nspanel.local:3232
[09:08:58][C][ota:101]:   Using Password.
[09:08:58][C][api:139]: API Server:
[09:08:58][C][api:140]:   Address: nspanel.local:6053
[09:08:58][C][api:144]:   Using noise encryption: NO
[09:09:53][D][binary_sensor:036]: 'nspanel Left Button': Sending state ON
[09:09:53][D][binary_sensor:036]: 'nspanel Left Button': Sending state OFF
[09:11:39][D][ads1115:186]: 'ADS1115 Channel A0-GND': Got Voltage=1.095875V
[09:11:39][D][sensor:094]: 'ADS1115 Channel A0-GND': Sending state 49.81250  with 3 decimals of accuracy
[09:12:02][D][sensor:094]: 'ntc_source': Sending state 1.70800 V with 2 decimals of accuracy
[09:12:02][D][resistance:039]: 'resistance_sensor' - Resistance 12016.1Ω
[09:12:02][D][sensor:094]: 'resistance_sensor': Sending state 12016.08008 Ω with 1 decimals of accuracy
[09:12:02][D][ntc:026]: 'nspanel Temperature' - Temperature: 20.9°C
[09:12:02][D][sensor:094]: 'nspanel Temperature': Sending state 20.92329 °C with 1 decimals of accuracy

Additional information

nextion editor

github-actions[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

edwardtfn commented 4 months ago

Looks like this issue is on the Nextion side. I've tried with a model NX4832F035_011C (the one used in NSPanel) and it failed, however when trying with a NX3224F024_011R it works just fine. Both are from Discovery series, and both running with fw v72.

I've used debug mode for uart, so I'm sure the thsp command is sent, but looks like the Nextion display just ignores that.