Problem with Nextion library upload example

I was trying to upload a tft file to nextion using Arduino Mega and SD card module with Upload example provided by Nextion library.. Here is my code:

#include "NexUpload.h"
NexUpload nex_download("test.tft",53,115200);
void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:

This returns:

12:32:00.184 -> start _checkFile
12:32:00.184 -> file is not exit
12:32:00.231 -> tft file size is:
12:32:00.231 -> 0
12:32:00.231 -> check file ok
12:32:00.916 -> get baudrate error

Any ideas?


is you screen configured at 9600 bauds and connected on pin 2 (Arduino Rx) and 3(Arduino Tx) ?

Thank you for the reply,
I am using Arduino Mega hence it is connected to 16(Arduino Rx2) and 17(Arduino Tx2) and screen is configured at 115200.

I'm not using their stuff but I would look into NexUpload.cpp to see the assumption they make.

How does the code know the screen is on Serial2?

Default conf file for this library, is for mega and it is on Serial2:

 * Define nexSerial for communicate with Nextion touch panel. 
#define nexSerial Serial2

Btw, I can manipulate a text field on Nextion through Arduino, which means Serial communication is established.


the error message you see

12:32:00.916 -> get baudrate error

comes from here

    if(_getBaudrate() == 0)
        dbSerialPrintln("get baudrate error");

so for some reason _getBaudrate() returned 0