A first program with ESP8266/ESP-01, CLion and PlatformIO

When using the ESP8266 you also meet the ESP-01 and his CH340G adapter. You can buy both at aliexpress.

esp-01 esp-01_programmer_ch340g

The Arduino IDE does not support coding with autocomplete, so I decided to use CLion. First you have to download an install CLion. (Don’t forget – CLion is not free)

Now install the Arduino and SerialPorts plugins:



Next you have to install PlatformIO. Because of working on a MacBook, I used Homebrew.

Next ist to install the Serial-to-USB Driver for the CH340.

So, now the preparations are finished. Let’s start to create an new project.

mkdir Blink
cd Blink
platformio init --ide clion --board esp01

To know, which board to use, you can use

platformio boards


platformio boards espressif8266

So, now we check, if the connection to the ESP8266 is working:

Plug in the ESP8266 and the programmer, but don’t bridge anything with a wire. Choose the port and the baud rate.


Now you can use the AT-commands for testing the communication.




Now open the project in CLion and create a source file. Pay attention, that the file ends with .cpp and write a small program like listed below. Don’t forget to #include "Arduino.h"


Wire the programmer like shown below

esp-01_programmer_wired esp-01_programmer_wired3

Connect it to the USP-port (maybe use a usb-hub for safety)
This small program comes from the examples in the Arduino-IDE (in the ESP8266-section):

#include "Arduino.h"
void setup() {
void loop() {
digitalWrite(BUILTIN_LED, LOW);
digitalWrite(BUILTIN_LED, HIGH);

Now compile and upload the program:


For compiling and uploading you can also use the build-button CLion_build_button, but never the run-button CLion_run_button.

When you want to upload again, you have to plug of and plug in again (?).





This entry was posted in IoT and tagged , , , . Bookmark the permalink.

3 Responses to A first program with ESP8266/ESP-01, CLion and PlatformIO

  1. Simon Ludwig says:

    Thank you so much!! Blogger like you are my rescue!

  2. kiraleouf says:

    Thanks for the tutorial,
    I was not able to use ESP on MacOS easily but with Clion and platform.io it works fine and it’s very nice to have the power of jetbrain IDE for iot dev 🙂

  3. Pingback: ESP32 Examples | Andreas' Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s