I am trying to send data from QSerialPort to Arduino Mega 2560. The proccess always takes some time to establish the connection.

How do I know with QSerialPort is the connections is ready to send data?

I don't know how much time do I have to wait for that and it happens every time when I run the application.

The configuration of my QSerialPort instance is:

mSerialPort = new QSerialPort();

I check the device configuration of COM port:

enter image description here

I also changed and play the Arduino delay but nothing changed.

I am sending to Arduino little piece of data. Example:

X100.10,Y10.23, H9999, ...others

And these data work when I am debugging the functions of my application. Everything is writting and work. So I am lost.

I hope all this information be usefull to give me an answer or at less some tips.


I am guessing that what you are seeing is not the port taking some time to open, but the Arduino resetting as soon as you open the serial port. That means there is a short time while it's in the bootloader looking for an "I am here" signal from avrdude. The timeout of that signal is configured in the bootloader, and is usually something like 1 second.

The simplest thing you can do is, as one of the first commands in your program, send an "I am ready to receive" signal to the computer (maybe just the word "OK" or something like that), which you then wait for before sending your data.

  • I just send a command from my Application with QSerialPort but it take a little time. I wait the answer from Arduino and after a 40 seconds I get the answer? I don't know why and I don't understand this behaviour – Robert Jun 11 '15 at 0:28
  • 40 seconds is unusual. It could be that you are sending the message too soon and the Arduino isn't receiving it. Add a delay of 2 seconds between opening the serial port and sending the message, see if that helps. – Majenko Jun 11 '15 at 12:39
  • I put an sleep of 2 seconds but nothing... it takes a long time to get an answer. – Robert Jun 11 '15 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.