Start a new topic

send serial data to Nextion

Hello,
I want to send data to the Nextion Display.
I create a checkbox, c0, ID: 1 in the Nextion Editor on page 0, page0.
How does the binary code look like to check the serial box?(65 00 01 01 FF FF FF)?
0100.001, 0000.0000, 0000.0001, 0000.0001, 1111.1111, 1111.1111, 1111.1111?

How would the correct binary code look like?
Best regards
Martin Heinze

You have the wrong idea about sending.


Checking the Send Component ID boxes for the checkbox (page 0 id 1)

will cause Nextion to send a Touch Return Data 0x65 when touch event occurs

https://www.itead.cc/wiki/Nextion_Instruction_Set#Format_of_Device_Return_Data


If the Touch Press Event for the checkbox (page 0 id 1) is checked 

  - Nextion will send to the MCU 0x65 0x00 0x01 0x01 0xFF 0xFF 0xFF when pressed

If the Touch Release Event for the checkbox (page 0 id 1) is checked

  - Nextion will send to the MCU 0x65 0x00 0x01 0x00 0xFF 0xFF 0xFF when released


When wanting to send from the MCU to the Nextion

   the checkbox (page 0 id 1 objname c0) is addressed as c0 - by its .objname

Sending the text c0.val=0ÿÿÿ would set the checkbox to the unchecked state

Sending the text c0.val=1ÿÿÿ would set the checkbox to the checked state


I am too lazy to convert the text to binary, but note ÿ is the char form of 0xFF


Since serial communications with Nextion uses the Least Significant Bit order

  c0.val=0ÿÿÿ in binary is:

    1100.0110,0000.1100,0111.0100,0110.1110,1000.0110,0011.0110,

        1011.1100,0000.1100,1111.1111,1111.1111,1111.1111

  c0.val=1ÿÿÿ in binary is:

    1100.0110,0000.1100,0111.0100,0110.1110,1000.0110,0011.0110,

        1011.1100,1000.1100,1111.1111,1111.1111,1111.1111

  c0 checkbox Touch Pressed Return Data 0x65 0x00 0x01 0x01 0xFF 0xFF 0xFF

    1010.0110,0000.0000,1000.0000,1000.0000,1111.1111,1111.1111,1111.1111

  c0 checkbox Touch Released Return Data 0x65 0x00 0x01 0x00 0xFF 0xFF 0xFF

    1010.0110,0000.0000,1000.0000,0000.0000,1111.1111,1111.1111,1111.1111

01001100 01101111 01101111 01101011 01110011 00100000 01100111 01101111 01101111 01100100 00100000 00101110 00101110 00101110

 

thank you, it works! :-) 

Login or Signup to post a comment