Important: Please read the Qt Code of Conduct -

Reading from Arduino using QSerialPort stops after a few bytes

  • Hi,

    I am trying to receive bytes from an Arduino's (emulated USB) serial port using QSerialPort.

    Currently I simply send an incrementing / overflowing single byte on the arduno side:

    void loop() {
    static unsigned char cnt = 0;
    Serial.write(&cnt, 1);

    When I connect to the emulated COM-port using putty, I receive an endless stream of bytes, as expected.

    However, when I try to achieve the same using QSerialPort, the Arduino sends for a short time (TX led is active), I receive a batch of bytes in one go but then the TX led stays dark and I don't receive any more data.

    if (! {
    printf("Error opening serial: %d\n", port.error());

    if(!port.setParity(QSerialPort::NoParity) ||
        !port.setStopBits(QSerialPort::OneStop) ||
        !port.setDataBits(QSerialPort::Data8) ||
        !port.setFlowControl(QSerialPort::NoFlowControl ) ||
        qFatal("Unable to configure serial port");
    char ackStatus = 0;
    while(1) {
        int bytesRead =, 1);
        if(bytesRead > 0) {
          printf("Data received, length: %d, val: %d\n", bytesRead, ackStatus);
        }else {

    Any idea what the difference between putty and QSerialPort might be in this case?

    Thank you in advance, Clemens

  • Lifetime Qt Champion

    Hi could you try the "Terminal sample"
    and see if it has same behavior?

  • I figured out, it was nescessary to set DTR:


    Thanks & br, Clemens