Reading data from serial port

Hi,
I’m trying to read data from the port on a Nextion display. I want to use a display button to tell the nextion to read 10 characters from the serial port. I can’t find any instructions for reading the port, and I’m sure there are instructions for that. Please help.

Here’s what I want to do… Button b1 is pressed, activating an event code that reads 10 characters from the serial port. The data gets moved into text box t1.txt.

This is not related to arduino or raspberry pi.

Thank you for your help

Andy

You’ll habe to put the Nextion into protocol reparse mode with the recmod setting. It will then stop interpreting the serial input as Nextion language ascii commands and write incoming bytes directly to a buffer, the so called u array which you’ll have to setup with the usize command, and where you can easily retrieve the bytes and handle them to taste with the ucopy and afterwards the udelete commands.
All these are well described in the Nextion Instruction Set document.

Thank you for your help. I have one other, general question. I am using this display to interface with a pre-made device that outputs a serial stream. This is not a processor I can get into. I can just read the stream. Therefore, the reparse mode should work fine.

But it seems like 99% of all posts about this device include the arduino or the raspberry pi. Are these screens specifically intended for use with a microprocessor platform, such as these?

In opposite to a simple, “classic” LCD display which would always need an external processor to be driven, the Nextion HMIs are somewhat “smarter”, since they have a built in CPU and memory. The primary goal of using a Nextion is to take off all the resource consuming burden of rendering (shapes, fonts, etc.) and driving the physical touch interface from the external CPU (Arduino, STM, PIC, whatever). Over the years, their internal CPU and the built-in programming language interpreter have become more and more powerful, so that, in certain specific and limited cases, the external CPU can be omitted and the Nextion used as a stand-alone solution. That’s not what they are designed for, it’s an interesting and sometimes challenging side effect.

1 Like

I have written the code for the display to read from the buffer and fill in the text boxes , I have also written code that lets the display do CRC16 in various polynomials not just modbuss here you will find code Inverter Remote Screen with a Nextion - AEVA Forums
Note it is also possible to write text directly to an area of the screen without a text box.
I am using it on its own with devices that expect a command + crc and send back an answer data + crc.

Thank you. This is very helpful.