Skip to content

ESP8266 programming from Eclipse

As most people developing SAP solutions are currently using Eclipse for their edge projects, I thought it would be convenient to write a blog on how to connect your Eclipse environment to the ESP8266.

Step 0: Get some ESP8266 chips and connect one to your computer

The ESP8266 chips can be bought from various sources. Great resources to get the chip are Ebay, AliExpress or Banggood. You can buy the bare ones, but you can also buy a development board along with it.

I’d highly recommend to buy a development board, because it makes life a lot easier. Most development boards allow you to just plus in your ESP8266 chip, and provide a USB port, leds and switches hardwired to the chip’s GPIO ports and even some contain relays, buzzers and photoresistors.

If you want to have a look at the board I bought to get started with, please have a look at my blog post “Getting started with the ESP8266“.

Step 1: Prepare your Eclipse environment for C programming

As most SAP developers won’t have their environment setup for C programming, this is the first step. To prepare Eclipse for C programming, the C developer tools (CDT) should be installed. To install the CDT, go to the market place (Help | Eclipse Marketplace), search for CDT and install it:

CDT in Eclipse Marketplace

During installation, you will the usual pop-up to accept the license agreement and eventually the installation end with the proposal to restart your eclipse environment (recommended). And that’s all there is to it. Once you have installed CDT, you’re ready to use your Eclipse environment for C programming as well, so you computer is ready, of course you can also use your computer for other things as video games with the use of services as boost CS:GO.

For now, just close Eclipse and proceed with step 2.

Step 2: Install the C compiler and ESP8266 SDK

To start programming the ESP8266, a few additional steps are necessary to install the ESP8266 SDK and the C-compiler though. Fortunately Mikhail Grigoriev has made these steps extremely easy by packaging a few smart installation scripts with the original SDK. His blog post “Работа с ESP8266 (working with ESP8266)“, was picked up by my embedded expert colleague Stijn van Drunen who kindly turned it into a blogpost on his own site stijnvandrunen.nl.

During installation, it’s recommended to use the default paths/folders as other components rely on that.

2.1: Download and install Mikhail Grigoriev’s Unofficial Development Kit for Espressif ESP8266.

2.2: Download and install MinGW. Get mingw-get-setup.exe from the official SourceForge project. During the installation uncheck the “… also install support for the graphical user interface” option as we won’t be needing it.

2.3: Mikhail Grigoriev made some awesome scripts to automate the installation of additional modules in MinGW which are needed for compiling. You can download his package here, extract it somewhere and then run install-mingw-package.bat.

Step 3: Import and run an example

Start Eclipse again and select to the C/C++ perspective (Window | Open perspective | Other):

Select C/C++ perspective

From the C/C++ perspective import one of the existing projects in the examples folder using “File | Import | General | Existing Project into Workspace”. If you then point it to e.g. folder “c:\Espressif\examples\hello_world”, you’ll import the hello_world program into your Eclipse workspace.

To build and upload the example, you will have to figure out which serial portal the ESP8266 is connected to, using the Windows Device Manager.

Serial port in Windows Device Manager

Once you know which serial port is is connected to, you can open the makefile and change the serial port in the make file (ESPPORT) accordingly.

While still in the C/C++ perspective, you’ll have a set of views on the right set, including “Make Target”. If you select it, you get a nice overview of all make-targets, including “All”, “Clean”, “Flash” and “FlashOneFile”. Once you have make sure the serial port in the makefile is set properly, set the ESP8266 to firmware mode (GIO0 = High during boot) and double click “Flash”. The firmware will then be build and flashed to the chip.

Please find an example of what this looks like in the video below:

To connect to the ESP8266 to see its output, you could use putty. By starting putty using the command below, you’ll connect to COM3 and can inspect it’s output.:

In the case of the hello_wold example, you should see “Hello World” being printed every second.

Step 4: Use the latests SDK

At the moment of writing, the latests Espressif SDK included in Mikhail’s Unofficial Development Kit is 1.0.1. However, to connect to SAP HANA Cloud platform, an SSL connection is required. As there have been quite some bug fixes in the SSL libraries, I would strongy advice to use SDK 1.1.1 instead.

To install the most recent development kit, please follow the steps below:

4.1: Go to directory c:\EspressIf and rename directory ESP8266_SDK to ESP8266_SDK_101.

4.2: Download EspressIf SDK 1.1.1 from http://bbs.espressif.com/download/file.php?id=484

4.3: Unpack the SDK zip file to C:\Espressif\ESP8266_SDK

4.4: Move all files and folders from folder C:\Espressif\ESP8266_SDK\esp_iot_sdk_v1.1.1 to C:\Espressif\ESP8266_SDK, and remove folder esp_iot_sdk_v1.1.1 afterwards.

Step 5: Modify the hello_world example to print the SDK version

The hello_world example currently prints only “Hello World” every second. To get the hello_world example to print the SDK version used to compile the program with, make the following modification:

Once you have flashed the modification, the ESP8266 should be returning “Hello World from SDK 1.1.1!” every second.

Catch: undefined reference to `user_rf_pre_init’

If you get this error message during compilation, it means that you have installed SDK 1.1.0 or above. SDKs of version 1.1.0 and above require you to define a new function that is not included in the samples yet. To define this new function, just open your user/user_main.c and add the line below at the bottom of the file:

What’s Next

In the next blog I’ll show you how to connect to SAP HANA Cloud Platform IoT Services straight from the ESP8266.

Update: That blog is in place now. You can find it here: http://www.penninkhof.com/2015/06/connecting-an-esp8266-to-the-hana-cloud-platform/

Published inSAP NetweaverTechnoblog

5 Comments

  1. Ben Ben

    When I get to the step in the video for “Clean”, there is an error shown in the console:
    xxx/Makefile:2: ../settings.mk: No such file or directory

    Indeed, there is no such file in the hello_world folder or its sub-folders.

    Likewise,
    xxx/Makefile:18: ../common_nonos.mk: No such file or directory

    Same problem reported here with no answer posted at this time, http://www.esp8266.com/viewtopic.php?f=9&t=820&start=452

  2. excellent info nto start esp8266 programimg

  3. Ayush Chand Ayush Chand

    IS there a way to use the eclipse environment for esp8266 in Linux?

  4. Ashok Vaishnav Ashok Vaishnav

    Hello, thanks for providing this tutorial to get started with esp8266 using c language in eclipse. I’m facing a problem. When I flash the blynky2 code, the code is being flashed onto my NodeMCU but the code doesn’t worked properly. Do I have to make any changes into makefile of the program? Please help me out.

Leave a Reply

Your email address will not be published. Required fields are marked *

5 × 4 =