Sleeping Nextion in sketch Arduino

Hey!

I’d want to would sleep screen Nextion NX4832K035_011 in my sketch of Arduino Wifi MKR 1010 and it wakes up some minutes later.

What is the error in the code?

Thanksss!

void setup() {
Serial1.begin(9600);
delay(500);
}

void loop()
{
//Serial1.print(0x86); //It doesn’t work it

Serial1.write(0x86); //It doesn’t work it
Serial1.write(0xff);
Serial1.write(0xff);
Serial1.write(0xff);
delay(1000);

//Serial1.print(0x87); //It doesn’t work it

Serial1.write(0x87); //It doesn’t work it
Serial1.write(0xff);
Serial1.write(0xff);
Serial1.write(0xff);
delay(1000);
}

When you send something to the Nextion display it returns something.
That can be turned off with the "bkcmd" command.

For some sleep instructions, there is always something returned, regardless if the "bkcmd" command was used or not.

The 0x86 and 0x87 are numbers that are returned by the display as you can read in the Instruction Set:

1 Like

Thanks Koepel!

With this code works it! :slight_smile:

Serial1.write("sleep=1");  //SLEEPING
Serial1.write(0xff);
Serial1.write(0xff);
Serial1.write(0xff);
delay(1000);
Serial1.write("sleep=0");  //AWAKE UP
Serial1.write(0xff);
Serial1.write(0xff);
Serial1.write(0xff);
delay(1000);
1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.