Arduino development using QtCreator IDE in Linux

Old No Comments on Arduino development using QtCreator IDE in Linux 3355

QtCreator IDE is one of the widely used IDEs when it comes to C++ application development. Although suited best for applications, it can also be used to develop Arduino sketches. This requires you to have the Arduino libraries and a package called arduino-mk which helps to make the Arduino hex file without using the IDE.

Create a plain new C++ (non Qt) project in the sketchbook directory where Arduino sketches are stored. This will create the project directory containing a main.cpp file.

Now, create a makefile named Makefile (without any extension) for use by the make utility within the project directory with the following contents:

ARDUINO_DIR = /usr/share/arduino
CPPFLAGS += -std=gnu++1y
include /usr/share/arduino/

If you installed Arduino in a separate directory, make sure to change the paths in the above makefile contents. Also ensure that the version number is correct.

Change the board tag to the one which you are using. You will find the list of boards in the file /usr/share/arduino/hardware/arduino/boards.txt. For most Linux users, the port will be something starting with ttyACM with a number appended, so an asterisk is used to fetch the proper port before upload. If you are using any extra libraries, uncomment the line containing ARDUINO_LIBS and add your libraries separated by spaces.

I have used the modern C++ standard for compiling, but you may omit the line for CPPFLAGS if you do not have the appropriate compiler (g++ 4.8 required). If you do not, I recommend upgrading to the latest version of gcc and g++ for more optimized compilation.

Rename the main.cpp file to <project_name>.ino. This converts it into an Arduino sketch. Write your Arduino setup and loop code after clearing previous code put by the IDE.

Then go to the project build properties and disable shadow build. Next, under build steps, delete the qmake step, as it is not needed. Only the make step is required which will do its work using the makefile created.

Then go to the project run properties and add a custom executable. Give the executable name as make and arguments as upload. Leave the build directory at default.

As you might have guessed, I have configured the IDE to upload hex file to Arduino whenever you run it. However, you will need a terminal to have serial communication. You can use gtkterm command as:

gtkterm --port /dev/ttyACMx --speed <serial_speed>

Replace x with the port and <serial_speed> with the serial rate. x will probably be zero for almost all cases, unless you have multiple Arduinos plugged in. Otherwise, try one, two, and so on. To precisely lookup the number, run dmesg | tail command just after connecting the Arduino. It will list the device ID for the Arduino just plugged in.

If you do not have gtkterm installed, install it using:

sudo apt-get install gtkterm

So now you have the power of Arduino libraries with the ease of QtCreator IDE to boost development times and unleash your Arduino powered system.


Vivek Prajapati

A moderate level programmer interested in administration and Arduino. Familiar with C++, Java, PHP, C# with my favourite being C++. Just finished my bachelor's degree in IT.

Related Articles

Leave a comment

Back to Top