bborncr / nextion

A simple Nextion HMI library for Arduino
GNU General Public License v3.0
127 stars 66 forks source link

Some functions don't work with Hardwareserial #25

Open raikoli opened 7 years ago

raikoli commented 7 years ago

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?

chinswain commented 7 years ago

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;