Sonoff NSPanel by ITead - Smart Scene Wall Switch based on ESP32 and custom Nextion Touch Screen Panel Display (non-Pro variant)

Not with the std Sonoff firmware…but if you were to flash to ESPHome , absolutely yes. I have a number of ESPHome based switches with momentary buttons that I have programmed to control both local and remote (via HA) brightness. I aim to have the behaviour consistent…single click to toggle. Press and hold …brighten to max, dim to min and repeat. If you release and hold again, change direction of the dim/brighten loop. (This is the behaviour of the old X10 LD11 dimmers and works very well).in some cases I also have double click do something in some case e…g Straight to max brightness.

Once you have ESPHome controlling the buttons on the NSPanel you have all the flexibility you could wish for to create this behaviour. I have an nspanel and dimmer on my test setup currently. I’ll try and create a quick example.

1 Like

Brilliant, that’s what I wanted to hear :slight_smile: I had thought about just using a plain old centre-off retractable switch, using the Shelly 2 dimmer module to give me the smart control, but as I’ll probably have a few smart devices in the intended room, I’m thinking of going for the nspanel instead.

Mashed my NSPanel and Dimmer control switch ESPHome code together…Left hand button controlling external HA connected dimmer. Press to toggle. Hold to Dim/brighten. Demo Here

2 Likes

You need to have the camera set to manual control to be able to get dimming on video.
Otherwise the camera will compensate to maintain a good exposure all the time.

Thanks for sharing that video Dean, it looks like it will do exactly what I have planned in that case. In terms of connections to the dimmer module you are using, that all looks straightforward. That’s convinced me to go for the nspanel and flash it with ESPHome. Not used ESPHome yet, but I have a smart plug with tasmota on that I will practice flashing on while waiting on the nspanel to arrive!

1 Like

Hi there,

I had the same problem when I powered up for the first time after flashing. After flashing, I changed the weather location to my location. The default in the Blakadder release is set to the North Pole. Use the ‘set_weather (your location)’ command to fix this.

Hi there @masto and @Tedsterh

Ribbon cable?? what ribbon cable?? Sadly I was “playing” with my NSPanel and it wasn´t properly seated and now as you said the screen doesn´t come off soooooo I was over the moon when I read your post but I don´t know what cable to fix or how :frowning: Can you please send a pic?? thanks in advance… obvs if it´s fixed after that I do owe you a beer in Madrid!!! what the hell… if it´s not fixed I owe you a beer too :stuck_out_tongue:

Do you mean that cable?? How on earth can you mess with that cable even if it´s not properly seated?

That’s what I am doing! Mock-up is ready and have already created some buttons and a more extensive music player.

Need to fix my issue with flashing the screen so I can test it.

10 Likes

Hi there,
Is it possible to turn on the NSPanel screen with a motion sensor ?

Oh WOW, please share this when you are ready. Love it

1 Like

I don’t understand everything you’re saying, but yes, that’s the cable I was referring to.

Some people disconnect it to take the board out, or just dislodge it in the process of moving things around. Flex connectors are fiddly. If the panel connects to ESPHome, but the screen doesn’t turn on at all, it’s one of the possible problems to check.

Yes, depending on how you set it up.

For example, I’m going down the ESP home route and using a modified version of https://github.com/marcfager/nspanel-mf

I can set the brightness to 100% when motion is triggered. It will automatically power down again after some time.

1 Like

Getting closer to getting my panel fixed so I can test it (the initial aligning) and will upload the working hmi/tft and config to GitHub after. Now running into a problem that the NSpanel disconnects during the tft upload so the upload fails and the thing appears to reboot:

10:51:35][D][sensor:125]: 'ntc_source': Sending state 1.58800 V with 2 decimals of accuracy
[10:51:35][D][resistance:037]: 'resistance_sensor' - Resistance 10388.8Ω
[10:51:35][D][sensor:125]: 'resistance_sensor': Sending state 10388.78613 Ω with 1 decimals of accuracy
[10:51:35][D][ntc:026]: 'Woonkamer NSPanel Temperature' - Temperature: 24.1°C
[10:51:35][D][sensor:125]: 'Woonkamer NSPanel Temperature': Sending state 24.14409 °C with 1 decimals of accuracy
[10:51:40][D][nextion_upload:169]: Connected
[10:51:40][D][nextion_upload:175]: Requesting URL: http://10.13.7.105:8123/local/nspanel_woonkamer.tft
[10:51:40][D][nextion_upload:209]: Updating Nextion NX4832F035_011C...
[10:51:41][D][nextion_upload:235]: Waiting for upgrade response
[10:51:41][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:41][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:41][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:41][D][nextion_upload:239]: Upgrade response is  4
[10:51:41][D][nextion_upload:242]: Available 0 : 0x00
[10:51:41][D][nextion_upload:242]: Available 1 : 0x00
[10:51:41][D][nextion_upload:242]: Available 2 : 0x00
[10:51:41][D][nextion_upload:242]: Available 3 : 0x05
[10:51:41][D][nextion_upload:246]: preparation for tft update done
[10:51:41][D][nextion_upload:283]: Allocating buffer size 65536, Heap size is 235460
[10:51:41][D][nextion_upload:305]: Updating tft from "http://10.13.7.105:8123/local/nspanel_woonkamer.tft" with a file size of 777652 using 65536 chunksize, Heap Size 167008
[10:51:41][D][nextion_upload:044]: Requesting range: bytes=0-16383
[10:51:42][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:42][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:42][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:43][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:43][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:43][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:43][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:43][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:43][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:43][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:43][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:43][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:43][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:44][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:44][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:44][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:44][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:44][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:44][E][uart:015]: Reading from UART timed out at byte 0!
[10:51:44][D][nextion_upload:117]: Nextion reported new range 526344
[10:51:44][D][nextion_upload:316]: Heap Size 171524, Bytes left 251308
[10:51:44][D][nextion_upload:044]: Requesting range: bytes=526344-591879
[10:51:50][D][nextion_upload:316]: Heap Size 178372, Bytes left 185772
[10:51:50][D][nextion_upload:044]: Requesting range: bytes=591880-657415
[10:51:56][D][nextion_upload:316]: Heap Size 178368, Bytes left 120236
[10:51:56][D][nextion_upload:044]: Requesting range: bytes=657416-722951
INFO nspanel-woonkamer.local: Ping timed out!
INFO Disconnected from ESPHome API for nspanel-woonkamer.local
WARNING Disconnected from API
WARNING Can't connect to ESPHome API for nspanel-woonkamer.local: Hello timed out
INFO Trying to reconnect to nspanel-woonkamer.local in the background
INFO Successfully connected to nspanel-woonkamer.local
[10:52:14][C][uart.arduino_esp32:105]: UART Bus:
[10:52:14][C][uart.arduino_esp32:106]:   TX Pin: GPIO16
[10:52:14][C][uart.arduino_esp32:107]:   RX Pin: GPIO17
[10:52:14][C][uart.arduino_esp32:109]:   RX Buffer Size: 256
[10:52:14][C][uart.arduino_esp32:111]:   Baud Rate: 115200 baud
[10:52:14][C][uart.arduino_esp32:112]:   Data Bits: 8
[10:52:14][C][uart.arduino_esp32:113]:   Parity: NONE
[10:52:14][C][uart.arduino_esp32:114]:   Stop bits: 1
[10:52:14][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Woonkamer NSPanel Left Button'
[10:52:14][C][gpio.binary_sensor:016]:   Pin: GPIO14
[10:52:14][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Woonkamer NSPanel Right Button'
[10:52:14][C][gpio.binary_sensor:016]:   Pin: GPIO27
[10:52:14][C][switch.gpio:048]: GPIO Switch 'Woonkamer NSPanel Relay 1'
[10:52:14][C][switch.gpio:049]:   Pin: GPIO22
[10:52:14][C][switch.gpio:071]:   Restore Mode: Restore (Defaults to OFF)
[10:52:14][C][switch.gpio:048]: GPIO Switch 'Woonkamer NSPanel Relay 2'
[10:52:14][C][switch.gpio:049]:   Pin: GPIO19
[10:52:14][C][switch.gpio:071]:   Restore Mode: Restore (Defaults to OFF)
[10:52:14][C][switch.gpio:048]: GPIO Switch 'screen_power'
[10:52:14][C][switch.gpio:049]:   Pin: GPIO4
[10:52:14][C][switch.gpio:071]:   Restore Mode: Always ON
[10:52:14][C][template.number:049]: Template Number 'Woonkamer NSPanel Brightness'
[10:52:14][C][template.number:049]:   Unit of Measurement: '%'
[10:52:14][C][template.number:050]:   Optimistic: NO
[10:52:15][C][template.number:051]:   Update Interval: 60.0s
[10:52:15][C][ledc.output:118]: LEDC Output:
[10:52:15][C][ledc.output:119]:   Pin GPIO21
[10:52:15][C][ledc.output:120]:   LEDC Channel: 0
[10:52:15][C][ledc.output:121]:   Frequency: 1000.0 Hz
[10:52:15][C][restart.button:017]: Restart Button 'Restart Woonkamer NSPanel'
[10:52:15][C][ntc:014]: NTC Sensor 'Woonkamer NSPanel Temperature'
[10:52:15][C][ntc:014]:   Device Class: 'temperature'
[10:52:15][C][ntc:014]:   State Class: 'measurement'
[10:52:15][C][ntc:014]:   Unit of Measurement: '°C'
[10:52:15][C][ntc:014]:   Accuracy Decimals: 1
[10:52:15][C][resistance:010]: Resistance Sensor 'resistance_sensor'
[10:52:15][C][resistance:010]:   State Class: 'measurement'
[10:52:15][C][resistance:010]:   Unit of Measurement: 'Ω'
[10:52:15][C][resistance:010]:   Accuracy Decimals: 1
[10:52:15][C][resistance:010]:   Icon: 'mdi:flash'
[10:52:15][C][resistance:011]:   Configuration: DOWNSTREAM
[10:52:15][C][resistance:012]:   Resistor: 11200.00Ω
[10:52:15][C][resistance:013]:   Reference Voltage: 3.3V
[10:52:15][C][adc:057]: ADC Sensor 'ntc_source'
[10:52:15][C][adc:057]:   Device Class: 'voltage'
[10:52:15][C][adc:057]:   State Class: 'measurement'
[10:52:15][C][adc:057]:   Unit of Measurement: 'V'
[10:52:15][C][adc:057]:   Accuracy Decimals: 2
[10:52:15][C][adc:067]:   Pin: GPIO38
[10:52:15][C][adc:082]:  Attenuation: 11db (max 3.9V)

I have an odd problem with the Esphome code causing the Nspanel not to boot after flashing it. It has happened with 3 different types of code entries. So far I have got round it by coming up with alternative ways of getting the pages to work but the latest problem is the final straw and I need to find out why it is happening as I have wasted far too much time trying to get it to work and finding alternative ways.

The latest example is with showing the current temperature of my Wiser radiator valves. Using the Nextion editor I have created a page with 6 text boxes on it that will show the temperature of a each room. The temperatures are pulled from Home Assistant by using 6 sensor entries in the Esphome code. I have tried each of the 6 code entries individually and they work correctly and show the temperate of that room in the text box on the page on the Nspanel. But I can only have any combination of code for 3 rooms active in Esphome. If I have 4 or more room code entries the Nspanel will not boot after flashing!

I have tried all combinations of the rooms code and if makes no difference which combination is used. Any combination of 3 rooms will work. As soon as you have 4 it will not boot.

Example of the Esphome sensor entries code is below :-

binary_sensor:
# Rooms Boost Buttons - Dining Room
  - platform: nextion
    name: $device_name Cancel button
    page_id: 9
    component_id: 23
    on_click:
      - homeassistant.service:
          service: climate.set_hvac_mode
          data:
            hvac_mode: auto
            entity_id: climate.wiser_dining_room

  - platform: nextion
    name: $device_name Boost 30 button
    page_id: 9
    component_id: 17
    on_click:
      - homeassistant.service:
          service: wiser.boost_heating
          data:
            time_period: '30'
            entity_id: climate.wiser_dining_room

  - platform: nextion
    name: $device_name Boost 60 button
    page_id: 9
    component_id: 20
    on_click:
      - homeassistant.service:
          service: wiser.boost_heating
          data:
            time_period: '60'
            entity_id: climate.wiser_dining_room

#  - platform: nextion
#    name: $device_name Boost 120 button
#    page_id: 9
#    component_id: 21
#    on_click:
#      - homeassistant.service:
#          service: wiser.boost_heating
#          data:
#            time_period: '120'
#            entity_id: climate.wiser_dining_room

#  - platform: nextion
#    name: $device_name Boost 180 button
#    page_id: 9
#    component_id: 22
#    on_click:
#      - homeassistant.service:
#          service: wiser.boost_heating
#          data:
#            time_period: '180'
#            entity_id: climate.wiser_dining_room

#  - platform: nextion
#    name: $device_name Boost Advance button
#    page_id: 9
#    component_id: 2
#    on_click:
#      - homeassistant.service:
#          service: wiser.boost_heating
#          data:
#            time_period: '30'
#            entity_id: climate.wiser_dining_room

With only the 3 sections active it works. If I uncomment any of other sections as well the Nspanel will not boot up.

Can anyone explain what I am doing wrong?

Thanks.

Here is my NSPanel. Graphics are not ready, but all works.

What do you think?

4 Likes

looking great… nice work…
i only hope that the Nextion Editor is going to be much easier to work with

I’ve just changed my sleep method to use the built in sleep instead of the button or the screensaver page. The big button was a pain when editing and the screensaver page only works if you have one page as far as I can see. If you’re on a different page, it’s always going to go back to the home screen. Not a big problem but I didn’t want to build in an issue.

So, I used the sleep method. It works fine apart form one thing. I have a motion sensor that switches the screen back on. In Node-RED, I have an nspanel_send_command with:

{"cmd":"click wake_button,0"}

That obviously won’t work now as the screen is asleep and won’t accept the command, and there is no button to click.

Does anyone know a way round this?

what if you would make a black screen as sleep screen, and whenever the Motion triggers you got the desired page, would that be a work around?!

Or maybe dim it to 0% and wake it up to full brightness in a lambda:

  • lambda: ‘id(disp1).set_backlight_brightness(x/100);’
    Something like this.

Or send a command sleep ==0 is wake up

  • lambda: ‘id(disp1).send_command_printf("%s", cmd.c_str());’

My take on the NSPanel plus me asking for some help…
I’ve tried to create something with the main purpose of easy control of lights in all rooms but with the possibility to go deeper into each room to control basically everything. Plus dynamic pages that pop up on special events: Knock on door, coffee brew, deactivate alarm…

Help is about the fact that I can’t add any more components to the code because that causes the ESP to not boot up. The code compiles and gets uploaded but it then just gets stuck with a flashing first page. Very annoying since I’ve come so far with the project. Flash memory is about 65% use but it feels like it has to much to initiate at boot up so it just gives up. Anyone has any ideas of what the root cause could be?

Code is uploaded on Github:
https://github.com/lillaeriika/NSPanel

7 Likes

Yes, I have also found it easiest just to use the built-in Nextion sleep command following the details on the topic in in the Nextion Instruction Set and the Nextion Sunday Blog series.

Some tips I’ve found on getting sleeping & waking to work properly:

  • Read the Nextion Instruction Set descriptions for System Variables ussp, thsp (currently not working on NSPanels), thup and usup, in particular taking note of setting thup=1 (to wake on touch) and usup=0 (to NOT wake on serial coms).
  • Even when the Nextion is in sleep mode with usup=0, it will wake by sending sleep=0ÿÿÿ (the ESPHome send_command() adds the ÿÿÿ termination to all Nextion Instructions for you). You just have to make sure you send that instruction first BEFORE you send the next commands you want to send, and include a short delay (to allow the Nextion to wake up).
  • There doesn’t seem to be a Nextion Event that you can use to reset things as the device wakes up. I’ve found it helps to set everything to be prepared for waking up (such as higher screen brightness etc.) immediately before calling sleep=1 in my Nextion Event code.
  • It helps if you have your own controlled way of putting the Nextion to sleep (rather than its internal time out settings or just sending sleep=1 from HA/ESPH) so as to ensure you have set it up to wake up in a controlled manner (given the previous point). (thsp isn’t working on NSPanels at the moment, but I don’t think I use it even it were - controlled sleeping is a better option.)

I have my own NSPanels working very well with sleeping (to black screen), progressive screen dimming while there is inaction, waking from sleep, and control of variable-speed update loops if you want to check out my HA Community posting or my code files on GitHub.

(edit)… and here is a motion automation to wake up the NSP from usup=0 sleep (I’ve edited in the notes about termination and the need for a delay I originally forgot to mention above):

# Wake NSP on motion
- alias: "Motion wake NSP1"
  trigger:
    - platform: state
      entity_id: binary_sensor.lounge_motion
      to: "on"
  condition:  # << Useful if you have a way to check the NSP isn't already in use
    - condition: state
      entity_id: sensor.nsp1_trigger
      state: "0.00"  # << indicates sleeping for Nextion Handler
  action:
    - service: esphome.nsp1_send_command
      data:
        cmd: sleep=0  #<< the ESPHome 'send_command()' will add the required termination string (0xFF, 0xFF, 0xFF = ÿÿÿ")
    - delay: 0.5  # <<<< note short delay to allow Nextion to wake up
    - service: esphome.nsp1_send_command
      data:
        cmd: page 0
1 Like