Metrika
Ivy Knob

ESP8266 SDK Comparison: Arduino/PlatformIO Part 2

ESP8266 SDK Comparison: Arduino/PlatformIO Part 2

In the previous post we talked about NodeMCU, firmware with Lua programming language. Today we will look at the Arduino SDK for ESP8266, adapted from the official SDK. It was initially done by @igrr, but now there are a lot of contributors and @igrr is part of Espressif organisation on Github.

PlatformIO is toolbelt for many hardware and software platforms. It supports ESP8266 with Arduino, NO-Os, FreeRTOS and Simba SDKs. It works from command line or as extension for Visual Studio Code or Atom code editors.

Libraries

PlatformIO have package manager included via platformio.ini file. It's modern package management tool. You can specify conditions for libraries versions. For example, use lib@1.1.1 to specify exact version of the package. You can also use git or github as a source for lib. So you have all necessary things to manage you dependancies.

If we look at Arduino libraries, there are a lot of libraries doing same thing with different names. If you try to search for mqtt client for ESP8266 (https://platformio.org/lib/search?query=esp8266 mqtt) you will get 3 pages of search results.

Moreover, most of the libs are coded without any rules and looks like spaghetti code. You will get compiler warnings and all that stuff.

And the "best" thing, that all the libs have different licences. So you can easily include GPL lib in your project. This is very bad thing.

Tooling

PlatformIO was initially built with great cli tooling in mind.You can build your code for multiple platforms with one command (or click), as well as run tests, upload code or open serial terminal to your board.

You can also upload code to remote agent. You can write code on your laptop and upload it to the home computer with connected board and get output.

Testing

Tests are core functions of PlatformIO. There are special cli command for that. Also, as well as code for different platforms, you can write tests for different platforms. For example, in our distributed sensor network project we have native code with its pack of tests and ESP8266 specific code with separate tests. And all these great things are just works with PlatformIO.

CI/CD compatibility

With such a great support of test and cli tooling it's really easy to use CI/CD tools. Native tests run without any problems on any linux machine. You can connect a board to a worker to run board specific tests. Or you can run tests via remote agent with the same result. In our distributed sensor network, we used gitlab ci to set up "test" and "build" pipelines.

Simplicity

s for simplicity, Arduino SDK uses C++ language, which is not easy to use. If you are not familiar with it, you will get a lot of problems. It's 100x times harder to write code comparing with NodeMCU Lua framework. You will spend time on writing code and debugging it. There are also memory leaks and all other funky C++ stuff.

Conclusion

Arduino SDK with PlatformIO is great toolset for ESP8266. It does support all modern and professional tools, eg tests and CI/CD. It uses low level C++ language with a lot of performance and complexity. It's harder to build simple things comparing with NodeMCU firmware. But if you need fast processing with math or some hard stuff, Arduino SDK is great choice. Just be aware of tricky libraries and packages with old spaghetti code and licences.