nextion
nextion copied to clipboard
Some functions don't work with Hardwareserial
I am using an Arduino Mega and use Serial1 for Nextion. Nextion.listen() works fine but getComponentValue or paged() return no values or wrong values. With SoftwareSerial all works fine but i can't use software serial in one special project.
Any ideas?
It seems to be a timing issue - If you add a delay before the command it works:
uint8_t Nextion::pageId(void){
sendCommand("sendme");
delay(200);
int a = -1;
String pagId = listen();
Serial.print("ID = ");
Serial.print(pagId);
Serial.println("<-");
if(pagId != ""){
return pagId.toInt();
}
return -1;