Start a new topic

Sleep - what is that and how to sleep?

1) How exactly sleep works? What it means? Screen is power off, but logic still working, right? Anything more to know?

2) Why sleep 1 used IN nextion touch event returns "invalid commant". it means that nextion can't go to sleep by itself?

I have no problem to sleep nextion from MCU, but how to assign sleep without MCU?

Thank you.

That is such a great question Mav.

- Passing out from exhaustion is not really sleep.  

- So how to sleep properly is a good point.

- Oh, sleep with Nextions ... sorry

Sleep usually implies powering down to lower levels of resource consumption

- sleep=1 will put Nextion to bed, a lower powered state with subset of functions running

- sleep=0 will wake the Nextion up, back to full power consumption, all functions running.

The power on default is sleep=0. 

So a power off and power back on will reset Nextion back to a fully powered state.

To sleep properly, one needs to be able to reawaken the Nextion, not just sleep=1

- so what is going to be our wake up trigger - this needs to be considered

- and under what conditions will Nextion doze off on its own.

- When we have these two things in mind, then we can proceed to set the conditions

There are three ways for the Nextion to doze off

  • Explicit command: sleep=1
  • No serial activity for 30 seconds  ussp=30
  • No touch activity for 15 seconds  thsp=15
But how can we get the Nextion to wake up
  • Explicit command: sleep=0
  • a screen touch.  But IF ONLY IF thup was set to thup=1

So power on defaults of the following system variables
  • sleep=0  // fully awake
  • thup=0    // will not wake up on touch activity
  • ussp=0   // will not doze when no serial data
  • thsp=0    // will not doze when no touch activity
  • dim=dims  // screen brightness is what user set in dims

Not everything will update when asleep - it is a reduced subset, slower clocking
- Variables may be out of wack, not reflecting what was sent during sleep mode
   - Important to wake Nextion to full if you expect full updates.
- The dim command is useful to simulate asleep (dim=0 before wake, dim=dims after sleep)
   - given in a recent post where user had issues of trying to update during sleep.

First touch press to wake Nextion if thup=1 only wakes
  - does not trigger component under the touch spot.

Now to trigger sleep in Nextion (sleep in 5 seconds)
  easy is code in a sleep timer, .en=0 .tim,=5000
     tm0.en=0  // turn timer off to not trigger over and over
     sleep=1     // enter sleep mode
  In a button, hotspot or fav method
      tm0.en=1  // turns your sleep timer on in 5 seconds

  In a button, hotspot or other fav method
      tm0.en=0  // turns your sleep timer off so you can abort

2 people like this

In case anyone else was interested in knowing how to handle sleep without a timer, on a page - here is what I did:

Add the following lines, on a page's post-initialize event - the Nextion will enter sleep in 16 seconds if no touch command, and wake by touch command:



2 people like this
Login or Signup to post a comment