Start a new topic
Not Taken


how to do PIC understand a send  touch event by NEXTION ? I have used a SERIAL MONITOR of arduino and I can identify the code. I have used code on the PIC:


#define   LED   (output(pin_c0))

char test;

 The code below is the touch event  

     print "D"
    print "L"


Please refer to the Nextion Instruction Set and the return codes the Nextion returns

In any Touch Press Event or Touch Release Event you have an option to check Send Component ID in the Nextion Editor (Refer to the Instruction Set for the Returned code formats for these events).

You can also use the print and printh commands in the Event Code sections and customize what is to be sent over the Rx/Tx in response to the touch event. (See Instruction Set for print and printh commands)

You will need to coordinate the design of your MCU code with the design of the HMI to suit your needs.

Information on how a PIC MCU might conduct serial is beyond the scope of this forum.

Also check the Free Chat section, as other users have used PICs in their projects.

I am now reviewing all of the Feature Requests, this will take some time, patience please.

Although this wasn't a real feature request, it is now marked as reviewed.

Future questions should be posted to the Free Chat Section

Hello Victor,

I am not having any success being able to communicate with the Nextion NX3224T024 and a PIC 16F887. I have a lot of experience using the PIC UART functions but for some reason I can not connect to this display. I built a very basic display page with a progress bar, button and text box. If I use a USB to TTL interface connected directly to the Nextion I can change the progress bar and read the buttons while using the debugger. 

I see you are also a PIC user so maybe we can put our heads together and find my mistake. 

Maybe you could share more of you code ?



Jim, just to rule a few things out.

You have experience using the UART so assume pushing and receiving chars/bytes are no issue.

What is the string of chars you are pushing to the Nextion to change a progress bar?

Are you terminating your data as per the Nextion Instruction Set?


You may have found my error. I did not know that I needed to terminate the data I send to the display with Nextion format . I have been using the debug in the editor to move the bar. I send it j0.val=65 and enter. The bar moves and so I thought that is all I need to do. I have attached my last attempt of very simple code. In frustration instead of a string I sent all the data one by one in DEC. No go however there is no special terminator other than cr/lf. 

I have a logic analyzer and I looked at the data going to the Nextion at the rx pin and it was perfect j0.val=65 cr lf. 

Thanks for listening



j0.val=65ÿÿÿ   where char ÿ is hex 0xFF dec 255

get j0.valÿÿÿ   returns 0x71 0x41 0x00 0x00 0x00 0xFF 0xFF 0xFF

t0.txt="Hey World"ÿÿÿ

See the Nextion Instruction Set Note under contents

with few exceptions all inbound and outbound are terminated 0xFF 0xFF 0xFF

Thanks again. I will be trying again in a couple of hours and will post my results. 

I can't tell you how many times I have read the instruction set. I even printed them. SO... under contents, notes I see this:


1. The instruction is end with three bytes "0xff 0xff 0xff"

2. All the instructions and parameters are in ASCII

3. All the instructions are in lowercase letters

I now understand that means received and SENT instructions. Because I saw the 

0xff 0xff 0xff terminator on the debug only for received data that is where I got mixed up. 

Hopefully the next post is success...



User instruction area is adding 0xFF 0xFF 0xFF terminators transparently

 - it is a hard char to type manually, not needing to enter in it there

   can cause confusion

Note that the Nextion Return Codes are also terminated.

If you were to examine the IteadLib Arduino Nextion Library,

- perhaps it could provide a glimpse as well


That issue is now behind me. Very simple fix when you know what your doing. I used this instruction and it works great.

UART1_Write_Text("j0.val=50ÿÿÿ ");

Next I will try to read .



More questions about serial communication with Nextion NX3224T024. I thought it would helpful if I could send and receive data from the display using a terminal program. I have used Tera Term for several years so I tried that. There is no response from the display. So then I thought it might be a level issue. So I used the same USB to TTL interface that I use when I hookup to the Nextion Editor. Still nothing RX or TX. Oddly I can send and receive OK with the editor. 

I went as far as to hookup my logic analyzer to the display and sure enough when I touch a button I get the string as described in the instruction manual.

Why cant I use a terminal program ??

Has anyone tried this before?



is your terminal program adding lf/crlf? 

Nextion does not use such and is ÿÿÿ    0xFF 0xFF 0xFF  terminated.

char 255 is difficult to reach, and ensure AnsiChar and not UTF-8/Unicode/WideChar


Yes, you can use a terminal program to test the communication with the Nextion display.

Do you use the correct baud rate?

You will find a screenshot in post #10 in following thread: