This is just a reminder to me for some ideas and notes about esp8266 programming.

Platformio

Platformio is just a big, complex, unvoidable helper tool to easily write code for microcontrollers. It supports different platforms (Espressif, ATMEL, ecc) and boards (Arduino, esp8266, ecc) and frameworks (Arduino, WiringPi, Simba, ecc.).

By default it comes with no gui. Is just a collection of tools written in Python 2 that are useful to initalize code (platformio init), compile for various boards and upload to the desired board (also multiple board at a time!).

Is very useful on CLI, but is much more easy on IDE, but instead of re-inventing an editor just for this (like Arduino did), it uses Atom. You can install the PlatformIO package from the Atom package manager and it installs also binaries (but not system-wide) for platformio or you cna download the Bundle Atom+PlatformIO from the Platformio webpage.

But you are not forced to use Atom as IDE, in fact you can also use Vim, Emacs or whatever you like. Major text editors (like Emacs) have a custom mode to call platformio commands and syntax colouring, autocompletion and so on.

The best and easiest thing to do IMHO is to download the Atom IDE + PlatformIO bundle directly from the page above.

platformio.ini

This file is created in every project init by PlatformIO. It contains basically information about the board, the vendor and the framework to use, plus some additional, optional items. An example:

[env:esp8285]
platform = espressif
framework = arduino
board = esp8285
  • The plaform key is used to know which compiler to use, options and so on. It also means to include (auto-include) certain libraries or others in your project.
  • The framework key is used to choose the (optional) framework. I can program ESP8266 with the Arduino framework because the Arduino guys did an excellent job in porting libraries for this platform too. This means I can use code like pinMode() and access GPIOs using the same (well, quite the same) syntax than Arduino. I think it controls autocompletion too. If you don’t need such framework, maybe because you want to write C code for ESP8266 using just the default, official ESP SDK, you can comment out this line. Imeediately PlatformIO re-generates all the project stuff (.clang_complete, .gcc-flags.json, the .pioenvs folder, …) to eliminate such dependency
  • The board key controls how PlatformIO communicates with the board (default serial settings, tools used to flash the firmware and so on).

Every time this file is edited PlatformIO automatically re-generates some files in the project folder.

Multiple ini stanzas can be specified. In this case multiple firmware will be generated (using the same code).