As an alternative to using the standard Arduino IDE you can also use the open source Eclipse C/C++ IDE platform when developing your applications that target Arduino compatible platforms. The Eclipse IDE is a more fully featured IDE that may be more familiar to those developers new to the Arduino world.
This story will walk you through the steps required to setup the Eclipse IDE for use in developing Arduino applications. We will concentrate on support for the NodeMCU development board variant but the same general procedure is applicable to a number of Arduino like platforms.
Doug Schaefer, developer and contributor to the Eclipse plug-in we will use, has published an excellent YouTube video that details how to download and install Eclipse. He then shows how to add support for Arduino code development by installing an Eclipse Arduino plug-in and finishes off by walking through creating your first Arduino app within Eclipse. This also includes adding external support libraries to the project.
After installing and configuring Eclipse using Doug’s video (and running a simple Hello World app) we will detail how to port a project created with the Arduino IDE to work within the Eclipse IDE.
We will refer you to Doug’s video for the "how to" details for getting setup and creating the Hello World, however please read through the following overview first. Doug's video installs the Arduino AVR platform, we will want to install the ESP8266 NodeMCU platform. So, please keep this in mind as you view the video and make the appropriate selections as mentioned in the overview below.
An overview of the video's stepsStep 1. Download and install Eclipse Nano C++ IDE per the video. This may all work with the latest version of Eclipse but we have only used the Nano version.
Be sure to download the "Eclipse IDE For C++ Developers" version from the following link: http://www.eclipse.org/downloads/packages/release/Neon/3
Step 2. Add the Arduino plug-in from the Eclipse Marketplace
Make sure the plug-in you add is the correct one, "Eclipse C++ IDE for Arduino 2.0". There is another Arduino plug-in, Sloeber, that may be a viable alternative but we do not have any experience using that one. Restart Eclipse when prompted.
Step 3. Add support for the NodeMCU (ESP8266) board to the Eclipse IDE.
Use the Arduino Download Manager plug-in (Help->Arduino Downloads Manager") to download the Arduino platform of choice. The video shows how to down load for Arduino AVR Boards, instead we want to download the “esp8266” platform for this workshop.
Step 4. New Board Connection
Add a new board connection by bringing up the Eclipse “Connection” view ("Window->Show View->Other->Connections->Connections). This works best if you plug in the NodeMCU board prior to adding the connection as it will attempt to auto populate the port name field.
Add a new connection using the Add Connection button that is within the Connection view. Choose NodeMCU 1.0(ESP-12E Module) board for our purposes. Ensure the “Upload Speed” is set to 115200.
The YouTube video link: https://www.youtube.com/watch?v=TtPvkPpAx0E
A write up that may or may not be totally in sync with the video can be found at: https://www.eclipse.org/community/eclipse_newsletter/2017/april/article4.php
Create a sample Eclipse projectStep 1. Create a sample hello world application.
Just follow along with what Doug shows for creating a Hello World app. This will help prove out the Eclipse environment before we proceed to the porting step. Note what Doug does with the second console, toward the end of the adding the new project. He moves it out of the view and pins it. This allows displaying the NodeMCU debug output.
Step 2. Adding an extra 3rd party library.
Doug shows downloading/adding an Adafruit library. This is useful if the library of choice has not already been downloaded when the platform was downloaded. The library we willbe using for the sample OneM2M demo, ESP8266WiFi, has already been downloaded when the platform was downloaded.
Port an existing Arduino sketch into an Eclipse projectNow we will detail the steps required to port an existing Arduino IDE sketch to work within the Eclipse environment.
Step 1. If you have not already Create a sample project within Eclipse.
Follow Doug's example for creating a new Arduino C/C++ project, use a name suitable for your activity. For this story we will name our Eclipse project OneM2M.
Step 2. When the project has been created copy the entire contents of your existing Arduino sketch into the new Eclipse project's main OneM2m.cpp file, replacing all of the default template code. The file name, OneM2m.cpp, depends on what you may have named your project.
Step 3. Add any required platform libraries.
For our example lets assume the Arduino sketch is wi-fi enabled and is including the Arduino ESP8266Wifi library.
This library is a platform specific library and has been downloaded automatically when you downloaded/added the ESP8266 platform during Doug’s video.
Step 3.1. Right click on your project name in the "Project Explorer" and select "Properties" and then "Libraries".
Step 3.2. Expand the "Platform Libraries" and then expand the "esp8266" entry on the right side of the dialog. Scroll down to "ESP8266Wifi" and select it.
Step 3.3. Click on the Dialogs "Ok" button.
Step 4. Add custom external source code files
There may be times when you need to pull in external source code files, for example if you choose to use a library that was not downloaded with the platform or perhaps just some custom source files included in the Arduino project. We will assume the files exist in some accessible directory. For our exercise we will assume we have a timer implementation that is contained within 4 files, 2 header and two .cpp files.
Step 4.1. Within your eclipse project, highlight your project in the Project Explorer view
Step 4.2. Right click on the project name, select Import
Step 4.3. At the Import dialog, expand "General", then select "File System" click "Next"
Step 4.4. At the next dialog, "Browse" to the location where the source files of interest reside. Here we see the source files we are interested in.
Step 4.5. click ok when you have selected the directory containing the files
Now you should see a list of file names on the right side if the dialog. Choose all of the .h and .cpp source files, then click "Finish".
Step 4.6. You should now see the files have been copied into your project.
Step 4.7. To build the project, click on the build button, the hammer icon at the top left of the main toolbar. At this point the project should build successfully with console output similar to that seen below.
Step 5. Update any application configure files
For our example we have assumed the NodeMCU application was using a Wi-Fi connection, thus at this point we would update any application custom configuration. For example we would set the WIFI ssid and password parameters as well as any IP host addresses that the application might require. Once that is done:
Step 6. re-build the oneM2M project to reflect these changes
Upload the oneM2M project code to NodeMCU board.Step 1. If you have not already created a new connection for your NodeMCU board, revisit the “New Board Connection” section above.
Step 2. Verify the currently selected Run, project name and connection name configuration items in the drop down tool bar boxes as shown in the following figure. Note the Selections “Run”, “OneM2M, and ESP8266Connection”
Upload the program to the NodeMUC board by clicking on the green button icon that is next to the hammer icon at the top right of the toolbar. This will probably cause a rebuild of the project before it is uploaded to the board. Below is sample output as seen in the Eclipse console window:
Step 1. When the upload completes the NodeMCU will automatically start to execute the application. To view the debug statement output messages, within the “Console” view click on the drop down arrow just to the right of the “Display Selected Console” button, select the item labeled “ESP8266 Connection” (assuming that is what you called the connection when you created it above). You should see some Wi-Fi connection messages as shown below.
Here we have shown how to install the Eclipse IDE for C/C++ Development and add in the Arduino support plug-in.
This was followed by creating a simple Hello World project. From there we discussed porting and Arduino sketch into Eclipse, followed by uploading and executing the sketch.
Hopefully this story has been helpful in getting you up and running, developing new NodeMCU applications using the Eclipse C/C++ IDE.
Special Attribution
Special thanks must go out to Doug Schaefer for the video and document regarding the Arduino plug-in as well as the entire Eclipse IDE development community without whose effort this would not be possible.
Comments
Please log in or sign up to comment.