Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFirmata on Windows 10
Qt 6.11 is out! See what's new in the release blog

QFirmata on Windows 10

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MScottM
    wrote on last edited by
    #1

    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?

    Pablo J. RoginaP 1 Reply Last reply
    0
    • M MScottM

      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?

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @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?

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • M Offline
        M Offline
        MScottM
        wrote on last edited by
        #3

        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'.

        aha_1980A 1 Reply Last reply
        0
        • M MScottM

          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'.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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

          Qt has to stay free or it will die.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MScottM
            wrote on last edited by
            #5

            @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

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MScottM
              wrote on last edited by MScottM
              #6

              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...?

              1 Reply Last reply
              0
              • M Offline
                M Offline
                MScottM
                wrote on last edited by
                #7

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

                M 2 Replies Last reply
                0
                • M MScottM

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

                  M Offline
                  M Offline
                  MrZhao
                  wrote on last edited by
                  #8

                  @MScottM I also encountered the same problem as you, could you tell me how you solved it? Thank you very much!

                  1 Reply Last reply
                  0
                  • M MScottM

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

                    M Offline
                    M Offline
                    MrZhao
                    wrote on last edited by
                    #9

                    @MScottM Error: SerialFirmata is not a type

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved