So now I have used the official Arduino IDE for some time to program the ESP8266. It is a convenient and quick-to-get-started method (check here). But recently I plan to write an application that I feel it would be uncomfortable to write codes using the limited features of Arduino IDE. I find particularly two feature-rich IDEs out there, which are free and highly recommended by communities, namely Atom and Visual Studio Code. With Atom, we need to add the PlatformIO extension for programming embedded systems, including the ESP8266. While with VS Code, we need to install either PlatformIO or Arduino extension.
I had difficulties to get both Atom-PlatformIO and VS Code-PlatformIO working. Somehow the PlatformIO installation was not able to complete. I suspected it was caused by my office internet proxy. I spent quite some time to solve it but did not succeed, so I abandoned it and tried the Arduino extension.
Getting the VS Code with Arduino extension working was not that straight forward either. If you search for the Arduino extension, you will find two choices, either developed by Microsoft or Steve Yin. Initially I chose the one developed by Microsoft. Well, Arduino extension is just an extension that allows users to tell the VS Code where the tools for compiling and uploading code reside. So we must have the official Arduino IDE installed because its tools for compiling and uploading will be used by the VS Code. Then we need to specify the Arduino IDE path in the VS Code ‘User Settings’. Btw, my OS was Windows 8, and I installed the official Arduino IDE version 1.8.2. For unknown reasons compiling sketch using VS Code was always fail with a message saying ‘[Error] Exit with code=undefined’. Actually, I also had an Ubuntu machine, and I managed to get the Arduino extension working. I could compile and upload codes to the ESP8266. But for some reasons, I still preferred to work on my Windows 8 machine.
So, then I gave the Steve Yin’s Arduino extension a try on my Win 8. The compile and upload options in User Settings were more complicated than those of Microsoft one. But happily I succeeded to compile and write bits of codes to the ESP8266 flash memory. The easiest way to specify the compile and upload options is by adapting them from the command list spat out from the Arduino IDE console output. Again, you can follow this instruction to program ESP8266 using Arduino IDE.
Here is my VS Code ‘User Settings’:
"arduino.uploader" : "C:\\Users\\User-pc\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\esptool\\0.4.9\\esptool.exe", "arduino.uploadOptions": "-vv -cd nodemcu -cb 921600 -cp COM12 -ca 0x00000 -cf $TARGET.bin", "arduino.compileOptions": "-compile -logger=machine -hardware D:/Master/arduino-1.8.2/hardware -hardware C:/Users/User-pc/AppData/Local/Arduino15/packages -tools D:/Master/arduino-1.8.2/tools-builder -tools D:/Master/arduino-1.8.2/hardware/tools/avr -tools C:/Users/User-pc/AppData/Local/Arduino15/packages -built-in-libraries D:/Master/arduino-1.8.2/libraries -libraries C:/Users/User-pc/Documents/Arduino/libraries -fqbn=esp8266:esp8266:nodemcuv2:CpuFrequency=80,UploadSpeed=115200,FlashSize=4M3M -vid-pid=0X2341_0X0043 -ide-version=10802 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.esptool.path=C:/Users/User-pc/AppData/Local/Arduino15/packages/esp8266/tools/esptool/0.4.9 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=C:/Users/User-pc/AppData/Local/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2 -prefs=runtime.tools.mkspiffs.path=C:/Users/User-pc/AppData/Local/Arduino15/packages/esp8266/tools/mkspiffs/0.1.2 -verbose",