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

QFirmata on Windows 10



  • I'm trying to start a project trying to control a servo on an Arduino from a Qt GUI. I'm trying to work with a project on GitHub: callaa/qfirmata but the installation instructions don't work (assume they are for Linux).

    I went ahead and created a blank QML project and added the primary Firmata file myself:

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QQmlEngine>
    #include "qfirmata-master/src/firmata.h"
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        QGuiApplication app(argc, argv);
    
        qmlRegisterType<Firmata>("Firmata", 1, 0, "Firmata");
    
        QQmlApplicationEngine engine;    
            const QUrl url(QStringLiteral("qrc:/main.qml"));    
            QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,    
                             &app, [url](QObject *obj, const QUrl &objUrl) {    
                if (!obj && url == objUrl)    
                    QCoreApplication::exit(-1);    
            }, Qt::QueuedConnection);    
            engine.load(url);    
        
            return app.exec();    
        }
    

    Then I added the files into the .pro file like so:

    SOURCES += \
        main.cpp \
        qfirmata-master/plugin.cpp \
        qfirmata-master/src/firmata.cpp \
        <snip - added them all>
    
    HEADERS += \
        qfirmata-master/plugin.h \
        qfirmata-master/src/firmata.h \
       <snip - added them all>
    

    and imported Firmata in my main.qml:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    
    import Firmata 1.0
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Firmata {
            backend: SerialFirmata {
                device: "COM4"
                 //Configure pin #13 as a digital output pin
                 //(On Arduino Uno and other boards, this pin has a built-in LED)
                 //The value of the pin (on/off) is bound to the value of the switch widget
                DigitalPin {
                    output: true
                    pin: 13
                    value: led_switch.checked
                }
            }
        }
    }
    

    (code is from an example in the Firmata folder)

    When I try to run this Qt complains that 'SerialFirmata is not a type', also, when I try different things to troubleshoot, it will complain that other things in the included files are 'not a type' such as DigitalPin, so I think I'm missing something fundamental.

    I'm wondering if anyone has gotten anything like this working on Windows 10?



  • @MScottM said in QFirmata on Windows 10:

    but the installation instructions don't work

    Please show any errors/output of what "didn't work"
    In addition, please describe your environment (so far we only know th OS, so state Qt version and compiler in use)

    As a workaround, could it be possible that you try using this QFirmata in a virtual machine with Linux?



  • Hi @Pablo-J-Rogina!

    Here is more info:

    Qt Creator 4.10.1
    Kit- Desktop Qt 5.12.3 MinGW 64bit

    The install instructions state:
    Build:

    qmake-qt5
    make
    

    Install (as root):

    make install
    

    I used the Qt 5.12.3 command window and changed directory to the qfirmata-master folder. Since qmake-qt5 is not a valid command, I used 'qmake' - this created various makefiles in the directory. Then I tried 'qmake install' and it reported 'cannot find file: install'.


  • Lifetime Qt Champion

    @MScottM if you read the instructions correctly, it's make and make install, not qmake install!

    You might need to replace make by mingw32-make though (assuming you use MinGW).

    Afterwards you can use it like any other Qt module.

    Regards



  • @aha_1980 said in QFirmata on Windows 10:

    mingw32-make

    Hi @aha_1980!

    Thank you for that suggestion - I didn't know 'mingw32-make' was possible. I tried it:

    mingw32-make
    

    then:

    mingw32-make install
    

    and it completed without errors. I tried to run the servo example, as suggested in the Github page by running it with qmlscene, but it failed reporting 'servo.qml:7 module Firmata is not installed'.

    I think I need to add a file: '\qfirmata-master\Firmata\qmldir' to the .pro file, but I'm not exactly sure how. I'll keep trying to figure this out!

    Best regards



  • Sorry to bump this! I've made a little progress, but now I'm seeing a different behavior and I need some help!!

    The SERVO example program compiled and ran once, but even though I can see the RX/TX lights flashing in response to the inputs from the GUI, the servo didn't respond (tried all possible pins & looked at pins that weren't selected by software). The next time I tried to run the program, it DID run, but Qt says it can't find the Firmata import:

    14366bcc-c814-43ff-baa5-6731ec1bba66-image.png

    What is going on!!?

    I'm continuing to try what I can think of, hoping someone has some insight!

    EDIT:

    I put the import path into the .pro file:

    INCLUDEPATH += $$PWD/qfirmata-master/imports/Firmata
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH += $$PWD/qfirmata-master/imports/Firmata
    
    

    And the error changed to this:

    QML module does not contain information about components contained in plugins.

    Module path: C:/Qt/5.12.3/mingw73_64/qml/Firmata
    See "Using QML Modules with Plugins" in the documentation.

    Automatic type dump of QML module failed.
    Errors:
    "C:\Qt\5.12.3\mingw73_64\bin\qmlplugindump.exe" returned exit code 3.
    Arguments: -nonrelocatable Firmata 1.0 .
    QQmlComponent: Component is not ready
    file:///C:/Qt/5.12.3/mingw73_64/qml/typelist.qml:3:1: plugin cannot be loaded for module "Firmata": The plugin 'C:/Qt/5.12.3/mingw73_64/qml/Firmata/qmlfirmataplugin.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)

    Wondering about the incompatible library...?



  • Solved - it's working. Issue was with the Arduino.


Log in to reply