Hi,
My Nextion display is sending corrupt data to the arduino ONLY if the here commented out code is added to the loop. The same problem occurs if I am using normal serial instead of Softserial.
The corrupt data looks like this in the serial Monitor:
⸮
⸮⸮
⸮⸮⸮
⸮⸮⸮⸮
⸮⸮⸮⸮⸮
⸮⸮⸮⸮⸮⸮
⸮⸮⸮⸮⸮⸮⸮
⸮⸮⸮⸮⸮⸮⸮⸮
⸮⸮⸮⸮⸮⸮⸮⸮⸮
⸮⸮⸮⸮⸮⸮⸮⸮⸮h
⸮⸮⸮⸮⸮⸮⸮⸮⸮he
⸮⸮⸮⸮⸮⸮⸮⸮⸮he⸮
Every row appears at a new button press on the Nextion touchscreen.
If I comment out the stuff which is also commented out in the attached code here it works as intended, the word "hello" is visiable in the serial monitor and the variable "trip" inside the if-condtion is changed to 3 as wanted.
Thanks in advance,
Johannes
#include <SoftwareSerial.h>
SoftwareSerial nextion(5, 6); // RX, TX
String data = "";
int trip,x;
void setup() {
Serial.begin(9600);
nextion.begin(9600);
}
void loop() {
if (nextion.available())
{
while (nextion.available())
{
data += char (nextion.read());
Serial.println(data);
}
}
if (data == "hello")
{
trip=3;
data = "";
}
/*
nextion.print("rpm.val=");
nextion.print(x);
nextion.write(0xff);
nextion.write(0xff);
nextion.write(0xff);
nextion.print("trip.val=");
nextion.print(trip);
nextion.write(0xff);
nextion.write(0xff);
nextion.write(0xff);
*/
x++;
if(x==100)
{
x=0;
}
}




