When using the ESP8266 you also meet the ESP-01 and his CH340G adapter. You can buy both at aliexpress.
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
or
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.
AT
AT+GMR
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
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() {
pinMode(BUILTIN_LED, OUTPUT);
}
void loop() {
digitalWrite(BUILTIN_LED, LOW);
delay(1000);
digitalWrite(BUILTIN_LED, HIGH);
delay(2000);
}
Now compile and upload the program:
For compiling and uploading you can also use the build-button , but never the run-button .
When you want to upload again, you have to plug of and plug in again (?).
Sources:
http://www.instructables.com/id/Getting-Started-With-the-ESP8266-ESP-01/
https://www.xgadget.de/anleitung/esp-01-esp8266-mit-adapter-programmieren-so-gehts/
http://www.ches.pl/using-platformio-get-started-arduino-clion-ide/
Thank you so much!! Blogger like you are my rescue!
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 🙂
Pingback: ESP32 Examples | Andreas' Blog