Secret Code

Arduino IDE 2.0 Beta

Liam Davies

Issue 45, April 2021

Live debugging, code auto-completion and a streamlined programming workflow are just some of the features available with the release of the new Arduino IDE 2.0 Beta. We take a thorough look.

The long-awaited overhaul of the Arduino IDE is here, and it’s awesome.

The Arduino IDE has long been a staple of the novice and experienced Maker toolkit, providing a simple and responsive interface for programming microcontrollers. Accessible to beginners and experts alike, the IDE deserves its place as a capable programming environment for electronics.

However, it’s no secret that the IDE is lacking in features that have been mainstream in other IDEs for many years. If you miss a curly bracket, or forget to initialise a variable, for example, the original IDE won’t let you know until it tries to compile the program! This was frustrating since nobody is immune to making simple mistakes in code.

Arduino’s new IDE 2.0 isn’t just an incremental improvement over the current version, it’s leaps and bounds ahead. We were blown away by the number of features added in the latest version, and how well they are implemented too.

The 1.x versions of the Arduino IDE were originally developed in Java, a language that Arduino stated is becoming difficult to integrate with other desktop applications due to its monolithic codebase. The new IDE is built on the Eclipse Theia framework, so users of Visual Studio Code may find many parts of the new IDE very familiar. With the new framework comes the powerful debugging and code navigation features that VS Code is renowned for.

Code Help

The biggest immediate feature we wanted to experiment with was the introduction of code auto-completion and syntax correction. As you type, a menu appears showing what valid options are available to complete your line of code. No longer do you have to navigate through forums and Arduino webpages to find the correct syntax. You will need to specify the board you are using from the Boards Manager in the Arduino IDE before using the new autocompletion feature, though.

Hovering over any function in your code will also reveal its parameters required and, if documented with comments, its functionality. With bigger programs, this will become super handy for getting a reminder of what function does what.

In addition, more advanced users can “peek” into the source code of a function being called by hitting Alt+F12, saving time by avoiding navigating through library source files. This greatly helps with understanding how and when external code is called from libraries.

In our opinion, these autocompletion features are the most useful additions for most Arduino IDE users. It transforms what was essentially a text editor into a fully-fledged coding environment.

Debugging

Live debugging in the Arduino IDE up until this point has consisted of using the serial monitor, by simply outputting the requested values in code. While Serial.print is useful, it only gets you so far when quickly debugging misbehaving code.

The new Arduino IDE 2 brings a powerful new tool onto the debugging playing field, adding breakpoints, live variable monitoring and modification. For those who haven’t looked into these debugging tools popular in modern programming environments, they essentially grant the programmer the ability to pause code at specific points and then inspect how the code runs by stepping through it. Imagine it as a slow-motion camera for programming.

IMAGE CREDIT: Arduino

It’s worth noting that this feature is limited to Arduino boards supporting SWD (Serial-Wire Debug) or JTAG, including the MKR family, Nano 33 IoT, Nano 33 BLE, Portenta, and the Zero. You will also need a debugging probe like the Segger J-Link and connect it to the SWD interface on the board - often small gold pads on the underside of the board. Once connected, these probes will allow attaching to an active process within the chips and provide access to breakpoints and the other handy debugging tools.

We’re excited to see this feature in action since it could also be a good method of demonstrating programming to beginners, showing exactly how the microcontroller steps through code, one line at a time.

Workflow

These headline features aren’t the only thing that has changed in the drastic overhaul of the IDE. We’re also presented with some quality-of-life improvements, making working with the IDE more convenient and customisable. We now have access to in-built visual themes and custom editor layouts that will look familiar to frequent users of Visual Studio. Want half the window for debugging and the other half for your source code? Simply drag and drop the editor windows.

Arduino IDE 2 brings a number of improvements to the way we write code. When writing a program, code autosaves and compilation is blazingly fast, thanks to the overhauled toolchain of the editor. In testing, a sizable program fully compiled and uploaded to an Uno R3 takes only a couple seconds.

Additionally, using multiple Serial Monitors is now possible. Previously, attempting to open another Serial Monitor in a separate editor window causes the IDE to complain about port usage. In the new IDE, opening up a new Serial Monitor to connect to two separate boards and interfacing with them simultaneously is now finally on the table.

Final Thoughts

While a powerful new array of features have landed for us makers, it’s important to note that Arduino was clearly quite careful when deciding what to change and what to carry forward in the IDE.

The toolbar options and GUI layout are virtually identical to the old version, however, the transition to an entirely new framework means that some parts of the editor respond differently. For example, the preferences and configuration windows now appear integrated into the editor window, instead of popping out when clicked. It didn’t take much for us to get used to the new layout, so long-time users of the program won’t be upset with the new changes.

Overall, we were pleasantly surprised with the new Arduino IDE 2.0. As many Arduino users have been moving to other IDEs with more features, it’s great to see the developers are keen to impress both beginners and those who have been using the Arduino boards for years.

The new IDE is available and open-source for makers to dig in. Just head over to: https://www.arduino.cc/en/software/

Download the latest experimental version (2.0.0-beta3 at time of writing). The IDE is still a beta version, so expect minor bugs and patches as time goes on. We’re excited to see what other features the Arduino team is working on next.