Using QtCreator for Arduino development

Introduction

I’ve been using QtCreator for some time now, mostly for Qt projects, and I really like the environment. It’s fast and have plenty of features for c/c++ development such as code completion, symbol navigation, and git integration.

Today I decided to try if I could use QtCreator for Arduino development and it turned out that it wasn’t that difficult. The environment isn’t perfect but it works and it doesn’t take much effort to set up a project.

Disclaimer: I’m not doing Arduino development regularly, I just find it amusing to toggle bits on 8-bit hardware now and then. If you find anything in this post that seems totally wrong please let me know.

Prerequisites

This tutorial assumes that you’re running Ubuntu. It shouldn’t be too difficult to adjust for other Linux distributions.

If you haven’t already installed the latest QtSDK (1.1.3), please download it from http://qt.nokia.com/downloads and do so.

Install arduino-core package from the Ubuntu repository

This should pull in required dependencies too, such as avr-gcc and avrdude.

Install gtkterm (optional, but recommended)

Creating a simple ‘Hello World’ project

You can create everything from within QtCreator but I find it easier to do the initial set up from command line.

If you look at the top of the file /usr/share/arduino/Arduino.mk you’ll find instructions on how to create a suitable Makefile for your project.

Here’s one that I use, just put the content in helloworld/src/Makefile

Finally create helloworld/src/app.cpp with the following content:

Importing the Hello World project

Start QtCreator and go to ‘File/New File or Project’ (ctrl+n) and then choose ‘Other Project/Import Existing Project’.

Finish the wizard by specifying ‘HelloWorld’ as ‘Project name’ and ‘<projects folder>/helloworld’ as ‘Location’. You might wonder why I specified ‘helloworld’ as project location instead of ‘helloworld/src’. This is because I don’t want QtCreator’s project files to end up in the same folder as my source. Just click on ‘Next’ on the following questions to finish the wizard.

QtCreator creates three files:

  • HelloWorld.conf – Add defines
  • HelloWorld.files – List all files that are part of the project
  • HelloWorld.includes – List all include paths

Add ‘/usr/share/arduino/hardware/arduino/cores/arduino’ to ‘HelloWorld.includes’. This tells QtCreator where to look for Arduino specific header files.

Configuring ‘Clean/Build/Run’
Click ‘Projects’ (ctrl+5) on the bar to the left to activate the project settings page to change the build and run settings.

Clean and Build settings
Change ‘Build directory’ to ‘<projects folder>/helloworld/src’ and modify the settings to reflect the screen shot below.

Run settings
Choose ‘Add Deploy Step’ and use the screen shot below to specify the settings.

If you didn’t install gtkterm you can specify ‘echo’ or something in the ‘Run configuration’.

The Hello World app
Finally I’ll write the code and upload/run it on the Arduino.

Open ‘app.cpp’ and change the code to the following snippet:

Press ctrl+r and hopefully you’ll see ‘Hello World’ printed each second in the gtkterm console.

11 Comments

  1. Nice, just started project using Arduino. This is useful. Post more about Arduino development.

  2. wally

    Do you think it’s possible to make a Arduino_project template (or project Wizard) for Qt-Creator ?

  3. Mario Boikov

    @wally I think I tried this but unfortunately I don’t remember the out come. Do take a look in the QtCreator template directory, you should find some example for simple C++ apps

  4. Hi,

    I made a template/wizard for Qt and Arduino, you can download it here :

    http://5lair.free.fr/SourceCode/Files/Qt_Creator_Arduino_Project.tar.gz

  5. fahmi

    @Sinclair excuse me but the file is not found 404.

  6. Slava

    Please notice, for ubuntu 12.10 (I am not sure since which version) you also need to install package arduino-cli which provides file /usr/share/arduino/Arduino.mk

  7. Very very good, can I debug my programs?

  8. LeiHuang

    How to switch this QT to window system,could you pls provide me the tutorial? syydbc@gmail.com Thinks

  9. Mattis

    Thanks, works great (QtCreator 3.6.0)

Trackbacks for this post

  1. A Better Arduino IDE — CyrusBuilt dot net

Leave a Reply