hello. I'm trying to send and receive data from nextion 2.8-inch display. for now, my communication is a success in sending and receiving. but I also received another unexpected value. i want to block that unidentified serial string.
yes, enter is the one I need. also, I need to divide it to yes and enter because I send them separate times. The other character (in product number) is unwanted. I need a perfect serial print here. thank you
I've moved your question to the Display section of the forum as that is where Nextion questions usually go.
What exactly is your unexpected string? Nextion displays do not send out 'unexpected' strings, well, OK you might not expect them but they are for a reason. Correctly configured, with appropriate code on your Arduino they only send things you want and need. If you are getting something you don't expect then you need to understand why and correct that.
I see nothing unexpected, as far as string printing binary data allows me to see,
maybe the answer of the Nextion is OK (x0.val was changed),
or invalid variable (if x0 does not exist on the current page)?
I think that is the 0xff 0xff 0xff that the Nextion sends with its data. The serial monitor can't display it properly so you get that.
There's nothing to fix, you just have to handle it in your code.
I have a tutorial at the top of the display section, in there you will find my methods and, in case you prefer them, a link so another tutorial by Seithan, he does things in a completely different way to me. Pick whichever suits you best. I am pretty sure @Whandall also has his way of doing things too.
I think you have set yourself an impossible target. I don't know exactly what you are doing, but I know I'd allocate myself a lot more than a few hours to a Nextion project. I've got a curry to make for a friend shortly, so my replies are going to stop soon...
#include <WhandallSerial.h> // https://github.com/whandall/WhandallSerial
// simple handler just prints some infos about the received line
void processLine(const char* buf) {
Serial.print(F("len = "));
Serial.print((uint8_t)buf[-1]);
Serial.print(F(", strlen = "));
Serial.println(strlen(buf));
Serial.println(buf);
}
SSerial nextionSerial(Serial1, processLine); // used serial and handler
void setup() {
Serial.begin(115200);
Serial1.begin(9600);
nextionSerial.begin(64, optTripleFF); // buffer size and options, maybe +optKeepDlm
}
void loop() {
nextionSerial.loop(); // collect chars and call handler for each line
}