QSerialport with arduino problem

  • Hi,
    i have a problem with comunication between pc and arduino uno.
    I have this code for communicating:

    int waitTimeout = 1000;
    if (serial->waitForBytesWritten(waitTimeout)) {      
        if (serial->waitForReadyRead(waitTimeout)){
            QByteArray response =  serial->readAll();
            qDebug() << "response" << response;
        } else {
            qDebug() <<"Wait read response timeout %1";
    } else {
        qDebug() << "Wait write request timeout %1";

    I want to send data and wait until arduino answers.
    Ok, it send data and waiting for response, but i getting the actual response and the previous response to.

    For example:
    I will connect the program with serial port and send first "message" , for example 12, and the first response is ok, i get 12.
    But when now i send, for example 78, the response is "1278".
    And then when i send for example 3, the response is "783".

    I´ve tried lots of possibilities, but nothing were good. Can you help me please. Thank you.

    Program in arduino works fine in terminal.

  • Qt Champions 2020

    You can try to check it with the Terminal example which comes with the QSerialPort

  • Yes, i made this program by the terminal example.

    I solve it. I use QStringList to delete the first response.

    But, i thank you for for answer.

Log in to reply