Code Craft: Using Eclipse For Arduino Development

As we work on projects we’re frequently upgrading our tools. That basic soldering iron gives way to one with temperature control. The introductory 3D printer yields to one faster and more capable. One reason for this is we don’t really understand the restrictions of the introductory level tools. Sometimes we realize this directly when the tool fails in a task. Other times we see another hacker using a better tool and realize we must have one!.

The same occurs with software tools. The Arduino IDE is a nice tool for starting out. It is easy to use which is great if you have never previously written software. The libraries and the way it ties nicely into the hardware ecosystem is a boon.

When you start on larger projects, say you upgrade to a Due or Teensy for more code or memory space, the Arduino IDE can hamper your productivity. Moving beyond these limitations requires a new, better tool.

Where do we find a better tool? To begin, recognize, as [Elliot] points out that There is no Arduino “Language”, we’re actually programming in C or C++. We chose which language through the extension on the file, ‘c’ for C and ‘cpp’ for C++. An Arduino support library may be written in C or C++ depending on the developer’s preference. It’s all mix ‘n match.

Potentially any environment that supports C/C++ can replace the Arduino IDE. Unfortunately, this is not easy to do, at least for inexperienced developers, because it means setting up the language tool chain and tools for uploading to the board. A developer with that much experience might eschew an integrated development environment altogether, going directly to using makefiles as [Joshua] describes in Arduino Development; There’s a Makefile for That.

The reality is the Arduino IDE is not much more than a text editor with the ability to invoke the tools needed to compile and download the code to the Arduino. A professional IDE not only handles those details but provides additional capabilities that make the software development process easier.

Eclipse CDT & Arduino Plug-In

Eclipse IDE

An alternative to the Arduino IDE is Eclipse, a development environment used by professional and hobby developers. It’s open-source software and extensible via plugins. Many developers have contributed to its development, including some with corporate support.

Eclipse based Arduino development uses two additions to the basic Eclipse IDE. One is the C/C++ Development Tooling (CDT). The CDT not only adds the C/C++ development capability but tools for automatic code completion and insertion, and also some code refactoring. Trust me, once you understand how to use these capabilities you’ll miss them dearly when not available.

The other addition is a plug-in developed by [Jantje Baeyens]. The plug-in is free and open-source.

This setup works in combination with the build environment for the Arduino IDE. You still need the IDE installed; you just don’t have to use it.

Earlier this year I installed Eclipse Luna with the plug-in and the Arduino 1.6.0 IDE while running Ubuntu 14.04. I just followed the installation directions on the Eclipse and plug-in sites and it went smoothly. Since then [Jantze] released a version of Eclipse Luna with the latest version of the plug-in pre-installed. I downloaded it and the 1.6.5r5 Arduino IDE recently. It works fine and installing updates for the plug-in is handled automatically by Eclipse.

When making a switch like this you need to know both where the current tool is inadequate, how the new tool addresses those limitations, and what additional benefits will accrue. We’ll address the limitations and how they are addressed first, and then the added benefits.

Arduino IDE Limitations


Editor Tabs

When projects get larger they obviously have more lines of code. Having hundreds or thousands of lines of code in a single file is a nightmare. Scrolling through that large a file to find a single line of code is time consuming. That is why compilers support splitting code into multiple files. Moving between editor windows is far easier than scrolling.

The Arduino IDE supports multiple files by adding more tabs. If you use INO files you’re only adding one at a time, but if you use C/C++ header and source files it’s two at time. With the Arduino IDE all the files have to be in open windows in order to be processed by the compiler. Sooner or later you run out of space across the top of the screen for more tabs.

eclipse project explorerMy 23″ monitor supports around 18 tabs and my 19″ side monitor about a dozen. Tabs for additional files scroll off to the right. They can be reached using Ctrl-ALT-Right, or through a drop down list on the right, which is cumbersome to use. To add insult, on my Ubuntu system the Ctrl-ALT-Right is used for changing workspaces so cannot be used for changing tabs.

Eclipse also uses tabs but they are only involved with editing. The files for a project are listed in a Project Explorer sub-window. Any file can be opened in the editor and closed when the editing or viewing is done. Having only the files open pertinent to your current activity reduces distractions. Eclipse also allows access to multiple projects to be available at the same time. This is useful if you want to get code snippets for your current project from an older one, or if you are working on two Arduinos that cooperate with one another.

Compilation Speed

The Arduino IDE copies every file to a temporary directory as an early step in the build process. This forces the build environment to see every file as changed, which in turn means the files are all compiled.

Under Eclipse the build does not move the files. The tool chain recognizes that once a file is compiled it does not need to be compiled again until a change is made in the source. In extremely large commercial projects this can literally save hours of time. Even in large hobby projects the time savings can be substantial.

Hunting for Errors

The console at the bottom of the Arduino IDE displays the compilation process and the errors that occur. The errors are listed with the file, line number, and the column of the error:

somefile.cpp:11:3: error: expected '}' before 'else'

To fix the error you need to find the file – ouch! if it’s on the drop down list – and then find the line in the file. This is time consuming.

Eclipse reports errors in two ways. The first is a console window similar to the one for the Arduino. The difference is you can click on an error and be taken to the line of code. Eclipse will even open the file if it’s not currently active in an editor. A real time saver.

The second is a list of errors in a “Problems” window stripped of all the compiler gobbledygook. Reading this list is much quicker than either IDE’s console window. By scanning the list you may see that the reported error is not the error that needs to be fixed. Sometimes errors, typos for example, are reported in multiple locations but the correction is elsewhere. The console window is still important because it provides the additional information that is sometimes needed to understand exactly what is causing the problem.

problem window

Terminal Annoyance

An annoyance with the Arduino IDE is the need to shut down the serial port terminal when you want to upload new code. The Eclipse solution manages this while keeping the terminal window open.

Note: This appears to have changed from the 1.60 to the 1.6.5 version of the Arduino IDE. If you are working with an older version and sticking with the Arduino IDE you should upgrade to the latest.

Eclipse Enhancements

Eclipse provides enhancements in addition to the improvements discussed above. Some of these are capabilities you don’t realize you need, but will love once you have them.

new class dialogCode completion is a simple enhancement that saves keystrokes and prevents errors by adding closing braces, quotes, brackets, parentheses, etc. This reduces errors due to omissions, and helps keep code better organized. (You do put braces around your if-clauses, don’t you? Apple didn’t, which created a security hole in their SSL processing, although there were a number of other problems with that code.)

As you’re working you often realize the name of a function, variable, or class is not exactly right. It needs to change. Hunting down a name in multiple files is daunting so you just let it go. Eclipse allows you to select a name, tell it to make the change, and all the occurrences will be changed.

Adding a new class requires creating new header and source files. A wizard does this for you. You enter the class name, a base class name if needed, and select if you want the constructor and destructor created. The files are created with skeleton source code and added to the project.

Wizards also can create new source or header files.

Creating the body of a function or class member is also automated once the function is declared. You first create the declaration in the header file:

 int something(const int a); 

and then you right click, select ‘Source’ and ‘Implement Method’. A skeleton definition is inserted into the source file:

int something(const int a) {

This is especially handy when the function has a long list of parameters.

Often you realize that some lines of code would be better as a new function. This may be so they can be reused in other locations, or just to simplify the flow in the current location. Lifting the code into a new function just requires selecting the code, right clicking, selecting ‘Refactor’, and ‘Extract Function’. A wizard opens for you to approve the new functions parameter list and when you accept this a call to the function replaces the lines and the new function is created.

To illustrate, one set of the duplicated code in loop() can be extracted into a function, outPins, and the duplicate code can be manually replaced with a call to the new function. Not an earth shaking example, admittedly, but it demonstrates the possibilities. The code starts as:

void loop() {
	static unsigned char cnt = 0;
	static bool state = false;

	analogWrite(pin09, cnt);
	// code to extract to make new function
	digitalWrite(pin11, state);
	digitalWrite(pin13, state);

	state = !state;

	// duplicate code
	digitalWrite(pin11, state);
	digitalWrite(pin13, state);

and after the refactoring becomes:

void loop() {
	static unsigned char cnt = 0;
	static bool state = false;

	analogWrite(pin09, cnt);

	state = !state;
	// replace next three lines with outPins(state);
	digitalWrite(pin11, state);
	digitalWrite(pin13, state);

and after a little cut and paste loop() becomes much simpler and maintenance of the lines now in outPins() is easier:

void loop() {
	static unsigned char cnt = 0;
	static bool state = false;

	analogWrite(pin09, cnt);
	state = !state;

Many of these capabilities are refactoring of code, a complex topic that is well worth studying if you will be working on larger projects. The techniques involved improve your code organization without changing the operation.

Caution: Eclipse will make the change you ask for so be sure you have it right. Fixing a massive automatic change can be a nightmare. Been there, done that.

This is just an overview of the advantages of using Eclipse in larger projects. If you are familiar with Eclipse chime in with other capabilities in the comments.

Plug-in Niceties

plugin dialogAll the above is what Eclipse brings. The Arduino plugin also provides a dialog that gives you control over the development parameters by replacing the Arduino IDE drop down menus. You no longer have to go to the menu to first select the board and then go back up to select the port. Also, the dialog allows you to specify compiler options that are buried down in a configuration file with the Arduino IDE. For instance, you can change from the standard optimizing for space to optimizing for speed.

An addition the plug-in brings is an ‘oscilloscope’ graphing window that displays properly formatted data as a curve. This is good for seeing how sensors are reacting to the environment.

Wrap Up

I’ve switched completely to using Eclipse for my Arduino projects. I was already comfortable with Eclipse for other projects so it felt good returning to it for the Arduino. The refactoring and auto-code completion were sorely missed and the other features are icing on the cake.

43 thoughts on “Code Craft: Using Eclipse For Arduino Development

  1. I develop embedded systems for my co-workers (physicists) to use. I started using the Arduino environment so that they can make code modifications, using the platform of their choice, out in the field. If I start using Eclipse as outlined above, what do I need to look out for to avoid writing code that they won’t be able to compile using the stock Arduino environment? Thanks.

    1. I haven’t really dug into the details so can only related my own experience. Perhaps others can help more and comment. Primarily you need an INO file that has the same name as the enclosing directory. The plugin will create one so that’s not a big hassle. I do move the code from that INO to a CPP file leaving the INO empty but that is just my preference. The one issue I’ve encountered is the Arduino IDE doesn’t pick up new files automatically, part of the ‘files must be open to compiler’ requirement. When adding an existing file the Arduino IDE wants to copy the file from its location to ‘its’ directory which results in the file being erased. I’d suggest you maintain an Arduino IDE workspace separate from the Eclipse workspace. When you release to coworkers copy the files from Eclipse to the Arduino, and add any new files using the Arduino IDE.

  2. I’ve resigned myself to having two installations of Eclipse on my working computer. One 32 bit and on 64 bit.
    I’m always looking for a way to consolidate more. But a pet peeve of mine is when you are required by some manufacturers and packages (I’m looking at you ChibiOS and TI.) to install yet another installation of Eclipse to use their toolsets.
    Plugins, people. Eclipse was developed with the capability! I just wish more toolsets were available that used them.

    1. This so much. It irritates me beyond belief when companies spin up their super-special eclipse package for something that could really just be handled as a plug-in. Sure, they might like to ensure they have a standard operating environment to write documentation against, but there’s nothing stopping them from having that SOE be “eclipse + plugin + specific configuration” and then just distributing the plugin as well.

      I don’t know, but it really shits me up the wall.

    2. For me, it works the other way round: Since I pay for every plugin with startup time and sometimes decreased stability, I’d rather have sets of plugins for separate types of work. So I have an eclipse installation for Java-development, one for large-scale C++ development, one for AVR C++ work, one for web-development, etc.

      That way, I also start in the right Eclipse workspace by starting a specific Eclipse instance.

      The great thing about Eclipse is that it supports both those approaches.

  3. Amen too all you said. Eclipse first seemed a little heavyweight for Arduino but once I got past “hello world” it became increasingly useful. Bonus that you didn’t mention — integration with version control tools including github.

    1. That is exactly why I went through the pain/pleasure of switching to Eclipse. The ability to try something on a branch, then realize that it was better/worse, without losing your original implementation is a huge benefit. “Arduino hacking” + “Good software development practices” + “Decent IDE” == “A really good time”

  4. I work with Visual Studio every day for my work, so I’m really happy that I found Visual Micro. I hope you will do a write-up on it too in the future.

    VisualMicro is a free plugin for Visual Studio (you can pay for the debugger and I did, but I hardly ever use it). It lets you use all the same keyboard shortcuts and features of Visual Studio, and you can keep using other useful plugins that you also use for Windows programs.

    And though you never even have to deal with the Arduino IDE when you use VisualMicro, it keeps all the files compatible with the IDE so when you post your code on Github, casual downloaders who still use the IDE can still use all the code.


  5. “Caution: Eclipse will make the change you ask for so be sure you have it right. Fixing a massive automatic change can be a nightmare. Been there, done that.”

    Thank goodness all good programmers use version control. Made a mistake? Roll it back and try again.

    1. What’s version control?? Sorry, couldn’t resist. I was actually in charge of setting up VC at one company in the mid-90s. Your point is good but a lot of Hackaday readers are hardware folks or newbies just reaching the point where they realize there might be a better way to do software. That’s my target audience. They’re not used to VC. Plus there is always the “One last change before I check it in. Oh, dang!”

  6. I’ve actually been using Xcode for AVR development for a while now with a plugin called X-AVR (Github: jawher/xavr).

    It’s quite a nice, simple environment for development, also very fast and snappy. It uses the avr-gcc and avrdude installed on your system by the makefile capability in Xcode.

    There’s nothing stopping you from adding the Arduino libraries to your project and using all the Arduino functions, although I’ve never done that.

    Personally I like to program for AVR without the Arduino library there’s lots of scope to make things run more efficiently and quicker as well as getting a better idea of what the AVR’s doing. Although I do use Arduino for quick prototyping which I’ll usually port to standard AVR C if it’s something I’m going to use a lot or requires a speed increase.

  7. Nice article Rud. My only (major) beef about Eclipse is that I, too, require multiple instances of Eclipse (try mixing JAVA/Javascript/PHP/Ruby and Python Eclipse plugs together .. no fun).

    But disk space cost is in the dirt so I guess I don’t object that much. And your points about code reorganzation tools as well as function completion and templating really shows that Eclipse is the way to go. But DO expect a learning curve WRT the Arduino IDE.

  8. I’ve worked with a number of software projects. Some of them were huge (mozilla, linux, emacs) some small (aiccu). I’ve always considered IDE-s like eclipse very heavy and problematic in terms of portability (think: sharing the code with developers who don’t share my love for my tools). I do recognise the benefits IDE-s can bring to some large closed projects, however, they also make writing crappy code in small projects a lot easier. Now I ask myself a question: how much source code do you manage in a “large” embedded project where the binaries are smaller than 32kB? Linux source code is ~600 MiB, binaries on my machine are ~100MiB. That means I’d expect a source code for ab Arduino project to be like 100 kB at most. What can Eclipse possibly give me I can’t get from the most basic tools?

    1. @steelman
      Jantje here the writer and maintainer of the arduino eclipse plugin.

      As to your question:”how much source code do you manage in a “large” embedded project where the binaries are smaller than 32kB?”
      I developed the plugin as I have a software background and have “bigger” projects.
      The robot I’m currently working on has 46 files (that is 23 classes) and uses 18 self written libraries (goes to 7000 lines of code).
      Managing this project in the arduino IDE will be far more time consuming than in a real IDE.
      As you can see below I only use 17% of the program memory of the mega. So still plenty of room left for the extensions I planned.

      On a side note: The fact I use 77% of the memory is due to the fact I use a 800 byte TX serial transfer buffer and 3 serial connections (=2400 bytes). So there is still room there to.

      Best regards

      AVR Memory Usage
      Device: atmega2560

      Program: 46288 bytes (17.7% Full)
      (.text + .data + .bootloader)

      Data: 6335 bytes (77.3% Full)
      (.data + .bss + .noinit)

  9. You don’t need to sell me on eclipse. I went from xemacs to eclipse more then 10 years ago, and have never looked back. If you have more then 100 lines in your sketch, it is worthwhile moving it to a real development platform!

    I mostly do Java now, but still work with a lot of (old) c/c++ libraries and eclipse handles if all!

  10. Eclipse is way too industrial to be the right “next step” for the Arduino IDE.
    It is clear as day that the Arduino build system needs an overhaul. AFAIK, they are slowly changing it with successive newer versions, and the arduino-makefile project has given people some options.

    Netbeans. Netbeans is the way to do it. More straightforward interface. It is totally in the open, and very mature. Sure, the interface is inexplicably slow, but it supports any toolchain, Makefile projects, has a plugin system, and does everything you would want an IDE to do.

    Take a look at MPLABX. That is free, no sign up to download, and works quite well.

    I recall seeing an Arduino-NetBeans plugin, but with a very long list of tinkering instructions to get it to work. The entire success of the Arduino IDE is that it contains all the tools. Even for the ESP board! Instead of having to find and install an exotic Xtensa compiler yourself, someone has already rolled everything together.

    So, someone should just roll a new Arudino IDE based on NetBeans, maybe under some cute name like ArduinoBeans … or as just a v2.0 of Arduino IDE.

    > My 23″ monitor supports around 18 tabs and my 19″ side monitor about a dozen.

    The fact that this has to be said just demonstrates how bad the problem really is.

  11. It’s very natural to keep upgrading your tools as you become a better maker. That is why every good maker ends up using Emacs eventually if they live long enough. I’m not sure why there need to be so many baby steps in the middle though. You could just graduate to Emacs right away.

  12. I am using Eclipse with the Plugin for a couple of years now. I works fine for me. Include I use SVN plug and Doxygen plugin. An now thate more and more platforms are made available. I can still stick with it. At work we use Visual Studio, Nothing wrong with that either.

  13. An OT here, but I noticed this first in eclipse: all of the sudden Java applications on my Windows 7 laptop stopped (or lag terribly) responding to mouse clicks. That also includes Java panel in windows menu. I am not sure, but it seems to have started when I tried out Eclipse IDE for Automotive Software Developers. I had no recent Java updates. Did this perhaps happen to anyone else here?

  14. I recognize so much in this post. In more evangelical moods, I try to get every Arduino user I know to move to Eclipse, mostly for the reasons described above.

    On the other hand, I also recognize that if you’re not an experienced software developer and have no prior experience with Eclipse, building up enough knowledge to find your way in such a complex IDE is quite an investment. For some time, you’ll be spending more time on getting to understand the relation between workspaces and projects than on writing actual lines of code.

    And that’s what maybe is missing from this article: it sums up all the niceties about Eclipse, but there’s not much said about how to get started with Eclipse if you’re an interested Arduino developer. And such information is quite scattered if you start looking for it. It would be nice if there was some friendly online community specifically for (beginning-) Eclipse AVR/Arduino developers.

  15. No, I have to say NO.
    Personally I’ve thrown Eclipse away since ~2005-6 (I couldn’t stand the inconsistency)

    But the point is; People going the arduino way are obviously looking for something ‘easy’ to handle,
    Eclipse is the exact opposite of ‘easy’.

    Go Code::Blocks (for all your C/C++ needs)

  16. This will tell I’m a grumpy old fart, but just have to say that to me using a mammoth like Eclipse for Arduino development seem like using a Hummer to reach the shop down the street to buy a newspaper :)

    1. I agree that for many people, Eclipse would be overkill. If you write small programs only, the *initial investment* is probably too big. Not all Arduino programs are small though. The Marlin firmware for reprap 3d printers, for instance is some 28 KLOC. Still not crazy big, but big enough to want a proper IDE.

      And the thing is: once you know how to set up a beast like Eclipse, it isn’t all that much trouble any more using it in your next project.

      I’ve been using Eclipse for all my (raw) AVR projects, mostly because I needed something that works for raw AVR development on Linux. But even for the small attiny13 projects (1K of program memory, so ~500 instructions) having a real IDE with real IDE features beats not having one.

    2. I waited to see if others would respond. Since they have I’ll add 2 cents from one slightly advanced gentleman: I was pleased to see the plugin because I am am familiar with Eclipse. I really missed the autocompletion, refactoring, and wizards for creating classes and other software constructs.

      Something I’m doing right now is writing and debugging some code on Linux that will eventually make its way into an Arduino system.

    1. @Drone
      Can you elaborate on the 2 issues you bring to the discussion? I run multiple eclipse instances, several versions (juno though mars) with different version controls (RTC and git) in different setups (egit and native git) on windows and linux and apart from the following 2 cases I have no clue what you are referring to.
      1) The version control tool RTC ( used as a plugin links to the code which makes it is not physically located in the workspace folder.
      2) Eclipse supports linking (which is a standard linux/mac feature getting more and more support in windows OS) which makes that files can be on a different location than it looks. This feature is however a functionality you as a end user (or the plugins you as a end user installed like RTC and the arduino eclipse plugin do) decide to use or not. Inside eclipse you can always see where the file is actually located.

      Please share your experiences in detail
      Best regards

  17. Eclipse?
    for some reason I thought it was 2015 and we were beyond this kind of nonsense.

    I’ve been a moderately satisfied user of this IDE for a few years, and even purchased licenses for Eclipse based tools such as FDT for SWF development, but the whole thing is too bloated and slow, especially for Mac users.
    I’ve used it for AVR development on a couple of projects, but every update can yield a surprise, so I gave up.
    the lest funny thing is when you open a project a year later and realise it won’t compile for whatever silly reason.
    I invite everyone to try Sublime Text 3 and the STino plugin.
    it works smoothly, often even with Arduino updates.
    the people supporting it are nice folks who just want a lightweight IDE for their everyday needs.
    go for branch ST4ArduinoIDE and use Arduino 1.6.4.
    it installs via Package Manager, instructions are supplied and you’ll be able to install “Arduino language” support.
    it’s Python based, and easy to customise, and although it’s not “free”, you can keep using it as long as you please without having to buy a license, just clicking OK on the popup every now and then.
    I’ve honestly given them my money, they deserve it: Best IDE I’ve ever used.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.