Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Cannot output a value using QSerialPort



  • I am not sure why Qt is not outputting a value in the GUI I have made using QSerialPort. The code compiles, and all the syntax is formatted correctly. I have tried looking at different forum posts, but I am unable to pinpoint the error.

    I am currently testing with a breadboard, circuit, and light bulb; all the hardware works and I am able to capture a voltage in the Arduino software (I can add the Arduino code if need be).

    The issue I am having is that I can't display a voltage in Qt. I am using an Arduino Uno and an Arduino Voltage sensor (VCC <25V).

    voltage_sensor.pro

    QT       += core gui serialport
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = voltage_sensor
    TEMPLATE = app
    
    # The following define makes your compiler emit warnings if you use
    # any Qt feature that has been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
        main.cpp \
        dialog.cpp
    
    HEADERS += \
        dialog.h
    
    FORMS += \
        dialog.ui
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    

    dialog.h

    #ifndef DIALOG_H
    #define DIALOG_H
    
    #include <QDialog>
    #include <QtSerialPort/QSerialPortInfo>
    #include <QByteArray>
    
    QT_BEGIN_NAMESPACE
    namespace Ui { class Dialog; }
    QT_END_NAMESPACE
    
    class Dialog : public QDialog
    {
        Q_OBJECT
    
    public:
        Dialog(QWidget *parent = nullptr);
        ~Dialog();
    
    private slots:
        void readSerial();
        void updateVoltage(QString);
    
    private:
        Ui::Dialog *ui;
    
        QSerialPort *arduino;
        static const quint16 arduino_uno_vendor_id = 9025;
        static const quint16 arduino_uno_product_id = 67;
        QByteArray serialData;
        QString serialBuffer;
        QString parsed_data;
        double voltage_value;
    };
    #endif // DIALOG_H
    

    dialog.cpp

    #include "dialog.h"
    #include "ui_dialog.h"
    #include <QSerialPort>
    #include <QSerialPortInfo>
    #include <string>
    #include <QDebug>
    #include <QMessageBox>
    
    Dialog::Dialog(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::Dialog)
    {
        ui->setupUi(this);
        ui->voltagelcdNumber->display("-------");
        arduino = new QSerialPort(this);
        serialBuffer = "";
        parsed_data = "";
        voltage_value = 0.0;
    
        bool arduino_is_available = false;
        QString arduino_uno_port_name;
        foreach(const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts()){
            if(serialPortInfo.hasProductIdentifier() && serialPortInfo.hasVendorIdentifier()){
                if((serialPortInfo.productIdentifier() == arduino_uno_product_id) && (serialPortInfo.vendorIdentifier() == arduino_uno_vendor_id)){
                    arduino_is_available = true;
                    arduino_uno_port_name = serialPortInfo.portName();
                }
            }
        }
    
        if(arduino_is_available)
        {
            qDebug()<<"Found the port \n";
            arduino->setPortName(arduino_uno_port_name);
            arduino->open(QSerialPort::ReadOnly);
            arduino->setBaudRate(QSerialPort::Baud9600);
            arduino->setDataBits(QSerialPort::Data8);
            arduino->setFlowControl(QSerialPort::NoFlowControl);
            arduino->setParity(QSerialPort::NoParity);
            arduino->setStopBits(QSerialPort::OneStop);
            QObject::connect(arduino, SIGNAL(readyRead), this, SLOT(readSerial()));
        } else {
            qDebug()<<"Could not find the correct port \n";
            QMessageBox::information(this,"Serial Port Error", "Could not open the serial port");
        }
    }
    
    Dialog::~Dialog()
    {
        if(arduino->isOpen())
        {
            arduino->close();
        }
        delete ui;
    }
    
    void Dialog::readSerial()
    {
        QStringList buffer_split = serialBuffer.split(",");
        if(buffer_split.length() < 3)
        {
            serialData = arduino->readAll();
            serialBuffer = serialBuffer + QString::fromStdString(serialData.toStdString());
            serialData.clear();
        } else {
            serialBuffer = "";
            qDebug() << buffer_split << "\n";
            parsed_data = buffer_split[1];
            voltage_value = (parsed_data.toDouble()) - 0.1;
            qDebug() << "Voltage: " << voltage_value << "\n";
            parsed_data = QString::number(voltage_value,'g',4);
            Dialog::updateVoltage(parsed_data);
        }
    }
    
    void Dialog::updateVoltage(QString sensor_reading)
    {
        ui->voltagelcdNumber->display(sensor_reading);
    }
    

    main.cpp

    #include "dialog.h"
    
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        Dialog w;
        w.setWindowTitle("Voltage Sensor");
        w.setFixedSize(434,122);
        w.show();
    
        return a.exec();
    }
    

    dialog.ui

    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>Dialog</class>
     <widget class="QDialog" name="Dialog">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>449</width>
        <height>157</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>Dialog</string>
      </property>
      <layout class="QGridLayout" name="gridLayout">
       <item row="0" column="0">
        <layout class="QHBoxLayout" name="horizontalLayout">
         <item>
          <widget class="QLabel" name="voltagelabel">
           <property name="text">
            <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:24pt; font-weight:600; color:#ff0000;&quot;&gt;Voltage&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
           </property>
          </widget>
         </item>
         <item>
          <widget class="QLCDNumber" name="voltagelcdNumber">
           <property name="palette">
            <palette>
             <active>
              <colorrole role="WindowText">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>0</red>
                 <green>0</green>
                 <blue>255</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="Light">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>20</red>
                 <green>20</green>
                 <blue>85</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="Dark">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>20</red>
                 <green>20</green>
                 <blue>85</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="Text">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>0</red>
                 <green>0</green>
                 <blue>0</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="ButtonText">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>0</red>
                 <green>0</green>
                 <blue>0</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="PlaceholderText">
               <brush brushstyle="SolidPattern">
                <color alpha="128">
                 <red>0</red>
                 <green>0</green>
                 <blue>0</blue>
                </color>
               </brush>
              </colorrole>
             </active>
             <inactive>
              <colorrole role="WindowText">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>0</red>
                 <green>0</green>
                 <blue>255</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="Light">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>20</red>
                 <green>20</green>
                 <blue>85</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="Dark">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>20</red>
                 <green>20</green>
                 <blue>85</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="Text">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>0</red>
                 <green>0</green>
                 <blue>0</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="ButtonText">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>0</red>
                 <green>0</green>
                 <blue>0</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="PlaceholderText">
               <brush brushstyle="SolidPattern">
                <color alpha="128">
                 <red>0</red>
                 <green>0</green>
                 <blue>0</blue>
                </color>
               </brush>
              </colorrole>
             </inactive>
             <disabled>
              <colorrole role="WindowText">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>20</red>
                 <green>20</green>
                 <blue>85</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="Light">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>20</red>
                 <green>20</green>
                 <blue>85</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="Dark">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>20</red>
                 <green>20</green>
                 <blue>85</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="Text">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>20</red>
                 <green>20</green>
                 <blue>85</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="ButtonText">
               <brush brushstyle="SolidPattern">
                <color alpha="255">
                 <red>20</red>
                 <green>20</green>
                 <blue>85</blue>
                </color>
               </brush>
              </colorrole>
              <colorrole role="PlaceholderText">
               <brush brushstyle="SolidPattern">
                <color alpha="128">
                 <red>0</red>
                 <green>0</green>
                 <blue>0</blue>
                </color>
               </brush>
              </colorrole>
             </disabled>
            </palette>
           </property>
           <property name="digitCount">
            <number>7</number>
           </property>
          </widget>
         </item>
        </layout>
       </item>
      </layout>
     </widget>
     <resources/>
     <connections/>
    </ui>
    

    Application Output

    Found the port
    


  • Maybe this statement doesnot work.
    QObject::connect(arduino, SIGNAL(readyRead), this, SLOT(readSerial()));
    Maybe the “readyReady” function lack of “()”,or you can try set breakpoint in slot readSerial() to ensure the slot is performed.


  • Qt Champions 2019

    @Simon-sun said in Cannot output a value using QSerialPort:

    Maybe the “readyReady”

    Not maybe - it does.

    Use the new signal/slot syntax to avoid such errors.



  • Thank you for the replies although I'm not 100% sure how I would implement this. Is there code I need to add, or even take away?


  • Qt Champions 2019

    Your connect statement is simply wrong and if you would have checked the return value you would have seen it by yourself. See https://wiki.qt.io/New_Signal_Slot_Syntax for the new signal/slot syntax



  • I just need to receive from the serial port, with the new syntax it requires a sender, &sender function which I cannot use / don't need



  • I changed QObject::connect(arduino, SIGNAL(readyRead), this, SLOT(readSerial())); to QObject::connect(arduino, 0, 0, 0, Qt::ConnectionType()); and I got the same output



  • @jude-bato said in Cannot output a value using QSerialPort:

    he new syntax it requires a sender, &sender function which I cannot use / don't need

    Please please take some time to read the link suggested for @Christian-Ehrlicher and try to understand the concepts of signal & slot under Qt

    Tip 1 : sender is a Qt object, and is the sender of a signal; an object that under some conditions will emit (send) a signal
    Tip 2: your sender is arduino object



  • I was reviewing the link and with trial and error I began trying to implement the new syntax. Saying that, part of the QObject::connect requires const char *signal which I have no idea what that means.



  • Reading on the new syntax I updated my Qt version as a troubleshooting method and put in QObject::connect(arduino, &QSerialPort::readyRead, this, &Dialog::readSerial); and the Application output is no member named 'connect' in 'QDebug'. I'm very lost


  • Qt Champions 2019

    @jude-bato Please show the code where you call connect()



  • @jsulm QObject::connect(arduino, SIGNAL(readyRead), this, SLOT(readSerial())); This is where connect should be called, but with the new syntax I very confused on how I can connect and read from Arduino into Qt


  • Lifetime Qt Champion

    Hi,

    You signal specification is still wrong in the connect statement.

    In any case, as already requested several times: please post the current code you are using.


  • Qt Champions 2019

    @jude-bato Why do you post again your old connect() call (which is wrong because the signal is missing brackets - readyRead())?
    Please post the code where you call connect() with new syntax (without SIGNAL/SLOT) and not just the connect() call itself but also the surrounding code...



  • QObject::connect(arduino, &QSerialPort::readyRead, this, &Dialog::readSerial); This is the code line that I have integrated in my current project, I'm just not sure how to convert it to the new syntax. I was using the old code because in the original question I wanted to specify where I was talking about. I know it was wrong and I changed it already. The problem I'm having is with the new syntax.


  • Qt Champions 2019

    @jude-bato And with that code line you get "no member named 'connect' in 'QDebug'"?



  • @jude-bato said in Cannot output a value using QSerialPort:

    This is the code line

    If you're looking for some help in the forum please make others' life easier.
    Why is so difficult to show some code snippet of yours? not just ONE line.
    Come on, some context helps understand what might be going on with your issue.



  • This is the code snippet, its in my dialog.cpp file

    if(arduino_is_available)
        {
            qDebug()<<"Found the port \n";
            arduino->setPortName(arduino_uno_port_name);
            arduino->open(QSerialPort::ReadOnly);
            arduino->setBaudRate(QSerialPort::Baud9600);
            arduino->setDataBits(QSerialPort::Data8);
            arduino->setFlowControl(QSerialPort::NoFlowControl);
            arduino->setParity(QSerialPort::NoParity);
            arduino->setStopBits(QSerialPort::OneStop);
            connect(*arduino, Dialog::readSerial(updateVoltage()),this,readSerial()); //too few arguments to function call, expected 1, have 0
        } else {
            qDebug()<<"Could not find the correct port \n";
            QMessageBox::information(this,"Serial Port Error", "Could not open the serial port");
        }
    }
    

    and the read serial code I have:

    void Dialog::readSerial()
    {
        QStringList buffer_split = serialBuffer.split(",");
        if(buffer_split.length() < 3)
        {
            serialData = arduino->readAll();
            serialBuffer = serialBuffer + QString::fromStdString(serialData.toStdString());
            serialData.clear();
        } else {
            serialBuffer = "";
            qDebug() << buffer_split << "\n";
            parsed_data = buffer_split[1];
            voltage_value = (parsed_data.toDouble()) - 0.1;
            qDebug() << "Voltage: " << voltage_value << "\n";
            parsed_data = QString::number(voltage_value,'g',4);
            Dialog::updateVoltage(parsed_data);
        }
    }
    

  • Lifetime Qt Champion

    Hi,

    One thing that is missing: you don't check that the open call is successful. You should add that.



  • @jude-bato said in Cannot output a value using QSerialPort:

    connect(*arduino, Dialog::readSerial(updateVoltage()),this,readSerial());

    Again, please read the documentation regarding signal and slots. You may want to try this article as well.

    Tip: a typical connect sentence has 4 elements, try to identify such elements within your code...

    Dialog::updateVoltage(parsed_data);

    Do you know why you're calling an static method here?



  • @SGaist I believe I do

    bool arduino_is_available = false;
        QString arduino_uno_port_name;
        foreach(const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts()){
            if(serialPortInfo.hasProductIdentifier() && serialPortInfo.hasVendorIdentifier()){
                if((serialPortInfo.productIdentifier() == arduino_uno_product_id) && (serialPortInfo.vendorIdentifier() == arduino_uno_vendor_id)){
                    arduino_is_available = true;
                    arduino_uno_port_name = serialPortInfo.portName();
                }
            }
        }
    
        if(arduino_is_available)
        {
            qDebug()<<"Found the port \n";
            arduino->setPortName(arduino_uno_port_name);
            arduino->open(QSerialPort::ReadOnly);
            arduino->setBaudRate(QSerialPort::Baud9600);
            arduino->setDataBits(QSerialPort::Data8);
            arduino->setFlowControl(QSerialPort::NoFlowControl);
            arduino->setParity(QSerialPort::NoParity);
            arduino->setStopBits(QSerialPort::OneStop);
            QObject::connect(arduino, SIGNAL(readyRead), this, SLOT(readSerial())); //I know this is wrong, this is what I'm trying to fix
        } else {
            qDebug()<<"Could not find the correct port \n";
            QMessageBox::information(this,"Serial Port Error", "Could not open the serial port");
        }
    }
    

  • Qt Champions 2019

    @jude-bato said in Cannot output a value using QSerialPort:

    I believe I do

    No, you don't check the value of QSerialPoort::open(). And you should set the parameter before opening the device.



  • @Pablo-J-Rogina I've already tried with the new syntax and I've tried with different elements and I keep getting the expected 1, have 0 output. As for the parsed_data I personally have never used it but I used Vannevar Morgan code as reference and it worked (https://github.com/vannevar-morgan/Qt-Temperature-Sensor/blob/master/DS18B20_Qt/dialog.cpp)

    @Christian-Ehrlicher Then I'm not sure how to go about doing so, I thought that mean to check if the port on the Arduino is open. When debugging I tested throughout my code and was open the Serial Port and read an open port on the Arduino, the only issue is I can't read anything from it


  • Lifetime Qt Champion

    How did you test that ?

    As for the call to open: again, always check that it succeeded. You might be trying to use an already opened device or you don't have the rights to open said device. Therefore, add that check before going further.



  • @SGaist I have

    Dialog::~Dialog()
    {
        if(arduino->isOpen())
        {
            arduino->close();
        }
        delete ui;
    }
    

    Would this satisfy the QSerialPort::open()?

    Also would I need to use connect? I change that line to just readSerial(); but I'm not able to implement void Dialog::updateVoltage(QString sensor_reading) into if(arduino_is_available)


  • Qt Champions 2019

    @jude-bato said in Cannot output a value using QSerialPort:

    Would this satisfy the QSerialPort::open()?

    Of course not, it does not have anything to do with open().

    if(!arduino->open(QSerialPort::ReadOnly)) {
        qDebug() << "Opening serial port failed";
        qDebug() << arduino->error() << arduino->errorString();
    }
    


  • @jsulm Thank you for your suggestion, I put in your code and I ran it again. This is what I got:1.png I'm so confused why my program isn't working correctly. I have a feeling that my problem has to do with reading from or something with making a connection with Arduino rather than the Serial Port itself.



  • @jude-bato

    First: please don't post screenshots, paste the text itself. It's easier for others to copy/paste/reply to that!

    Device is already open

    Have you seen this message?
    What do you think about that? My bet is that you also have other program (i.e. Arduino IDE) connected to your device...


  • Qt Champions 2019

    @jude-bato Exactly what @SGaist was suggesting



  • @Pablo-J-Rogina I have an Arduino Uno connected via USB, that's my original point in making the forum post is because I am unable to capture a voltage in Qt from it. I have it stated in my original post.



  • @jude-bato said in Cannot output a value using QSerialPort:

    I have an Arduino Uno connected via USB,

    Yes, I assumed that. What you should know, if not aware yet, is that you cannot have two applications (i.e. your Qt app and the Arduino IDE) using the same port simultaneously



  • @Pablo-J-Rogina So how can I just read voltage from my Arduino Uno in Qt



  • @jude-bato said in Cannot output a value using QSerialPort:

    So how can I just read voltage from my Arduino Uno in Qt

    Since you haven't describe your environment/use case so far, I'll assume that you have a program running on the Arduino board, and that program reads some sensor and it outputs such readings via serial.

    So with that assumption, I expect you to go through something like this:

    1. Write the Arduino code, and via Arduino IDE deploy it on your Arduino device
    2. Close the Arduino IDE
    3. Start Qt Creator and write a Qt application that will read the serial port and display the readings on screen
    4. Run your Qt application
    5. Success!


  • @Pablo-J-Rogina Thats exactly what I'm trying to do. I read upon this article: https://forum.qt.io/topic/64696/sending-a-data-to-arduino-through-serial-port-using-qt and it is a similar problem to the one I'm having, for some reason Qt is not reading from the Arduino at all. It recognizes it but it's not reading from it. Here is my Arduino IDE code:

    int offset = 20;
    
    void setup() 
    {
      Serial.begin(9600);
    }
    
    void loop()
    {
      int volt = analogRead(A0);
      double voltage = map(volt, 0, 1023, 0, 2500) + offset;
    
      voltage /= 100;
      Serial.print("Voltage: ");
      Serial.print(voltage);
      Serial.println("V");
    
      delay(500);
    }
    

    I've tried doing you recommendation but I'm having difficulties with Qt and grabbing information off Arduino.
    Picture of Arduino working properly



  • I am testing the hardware and I see that when I use the Arduino IDE or the Qt code they both work the same way and allow for a reading to happen I believe it is something to do with the GUI that I have designed that would allow for the values to be shown I will try and change it up and see if anything happens. I've been reading many many forum posts and it seems that my code is fine because it compiles and it works the same way when running the board through the IDE.



  • @jude-bato I don't know why I didn't yet suggested to check with some Qt examples, anyway. What if you try building and running:
    Command Line Reader Async Example (no GUI, just to test you are able to receive data from Arduino...)
    Terminal "Terminal shows how to create a terminal for a simple serial interface by using Qt Serial Port."



  • @Pablo-J-Rogina I ran the example and the Application Output I got was:

    16:00:11: Running steps for project creaderasync...
    16:00:11: Configuration unchanged, skipping qmake step.
    16:00:11: Starting: "C:\Qt\Tools\mingw730_32\bin\mingw32-make.exe" -j8
    C:/Qt/Tools/mingw730_32/bin/mingw32-make -f Makefile.Debug
    mingw32-make[1]: Entering directory 'C:/Qt/Examples/Qt-5.12.6/serialport/build-creaderasync-Desktop_Qt_5_12_6_MinGW_32_bit-Debug'
    mingw32-make[1]: Nothing to be done for 'first'.
    mingw32-make[1]: Leaving directory 'C:/Qt/Examples/Qt-5.12.6/serialport/build-creaderasync-Desktop_Qt_5_12_6_MinGW_32_bit-Debug'
    16:00:12: The process "C:\Qt\Tools\mingw730_32\bin\mingw32-make.exe" exited normally.
    16:00:12: Elapsed time: 00:01.
    

    Example Output
    I'm not sure of the result this is a little foreign to me.

    Looking back on my code I figured something out. When I have

     if(arduino_is_available)
        {
            qDebug()<<"Found the port \n";
            arduino->setPortName(arduino_uno_port_name);
            arduino->open(QSerialPort::ReadOnly);
            arduino->setBaudRate(QSerialPort::Baud9600);
            arduino->setDataBits(QSerialPort::Data8);
            arduino->setFlowControl(QSerialPort::NoFlowControl);
            arduino->setParity(QSerialPort::NoParity);
            arduino->setStopBits(QSerialPort::OneStop);
            QSerialPort::connect(arduino, &QSerialPort::readyRead, this, &Dialog::readSerial);
        } else {
            qDebug()<<"Could not find the correct port \n";
            QMessageBox::information(this,"Serial Port Error", "Could not open the serial port");
        }
    

    I also have:

    void Dialog::updateVoltage(QString sensor_reading)
    {
        ui->voltagelcdNumber->display(sensor_reading);
    }
    

    which is never called. And when I tried to call it in the previous code I get the error:

    too few arguments to function call, expected 1, have 0
    

    If I am able to implement the update voltage into my previous code I believe it will work. My issue now is how am I supposed to get around this error. When I hover over it, it says it requires a QString, I have tried everything to try and get around this error.



  • @jude-bato said in Cannot output a value using QSerialPort:

    I'm not sure of the result this is a little foreign to me.

    Sorry but it's evident that you don't read the documentation...
    When running the command line example, please check the arguments it needs...


  • Lifetime Qt Champion

    Hi
    Why not try the same
    https://doc.qt.io/qt-5/qtserialport-terminal-example.html
    as @Pablo-J-Rogina linked to ?
    Its a littel serial comm GUI that can easy open a serial port and
    read and write to it.
    Very good for testing out if the Arduino responds as expected.



  • @mrjj @Pablo-J-Rogina I ran both examples and since this is my first Qt project I'm not exactly sure what I'm looking for. I have attached my results.
    Simple Terminal
    I know that my Arduino works already because I have tested it in the Arduino IDE as well as when I am debugging my code. I already know that everything works, my issue is just being able to display it. That second example is similar to what I want to do expect having my own GUI. Many thanks for all the responses thus far!


Log in to reply