PlatformIO: An alternative to Arduino IDE and a complete ecosystem for IoT

PlatformIO Logo

As an introduction I would like to make clear that I’m not a C++ advanced coder or IoT professional, I do this just because it’s a challenge, and because it’s a lot of fun compared to my 9 hrs/5 days a week web developer doing PHP and Admin panels for clients in Germany. Two months ago I started tinkering with SPI Cameras and the Espressif systems boards and that’s how this open source project was born. So far I was using Arduino since I do not need a super IDE, sometimes I also edit the code with vi or gedit instead of open a monster IDE that will eat your CPU alive. But gladly this is not the case. I was since long looking for a competitive alternative to Arduino when this github issue on the FS2 Camera Project called my interest:

tablatronix commented 8 days ago

I had to manually install this button library as it is not in platformio , is it in arduinos?

And that’s how after a few clicks I discovered that according to their home page it’s an open source IoT ecosystem. But what interested me more than this is the subtitle:  “Cross-platform IDE and unified debugger. Remote unit testing and firmware updates

So instead of answering tablatronix issue, I started installing this new IDE, that happened in a breeze.
1. First thing is to install the VS CODE Version. I choosed the Visual Studio code option since it has more features. Microsoft’s Visual Studio Code is the base and PlatformIO is built on the top of this.

2. Go to “Extensions” and install PlatformIO IDE “Development environment for IoT, Arduino, Espressif (ESP8266/ESP32)”

platformio IDE extensions is marked in RED just before PlatformIO logo

3. In my case since I used Arduino IDE before, go to PlatformIO alien face logo and select “Import project from Arduino”. Then select the folder where your Arduino project is and PlatformIO will create a Workspace for you with all the necessary structure.

4. Adjust serial monitor baud rate.  If you are using Espressif chips edit platformio.ini and add the following line at the end:

monitor_baud = 115200

This will make your serial work in the right baud rate for ESP8266 /ESP32 (Serial is the plug icon in the bottom just before the Terminal > icon)

5. FS Data. If you are using SPIFFS that in Arduino is the /data folder inside your sketch you will notice that in PlatformIO this folder needs to be at the root level. So you can simply move it one directory above. To upload SPIFFS data use the following command in the terminal:

pio run --target uploadfs
IMPORTANT: As difference with Arduino if you try to save a file in /1.JPG here you will get it saved on:
/spiffs/1.JPG so create this folder on /data or you will get; VFSFileImpl(): fopen(/spiffs/1.jpg) failed

6. Libraries in PlatformIO live inside a folder on your project called .piolibdeps Thanks god, they are not distributed on 3 different parts, like it happens with Arduino (Some in Arduino/libraries, some in Programs/Arduino/libraries and so on) but are there available for you in just one place :)
To install a new library is very easy, just go to and type the name of the library to search. If found copy the resultant line in the Terminal just like point 5 and the IDE will look this up for you and download it using github to the  .piolibdeps folder.

pio lib install "WifiManager"

Sometimes you will need a library in a special branch and there is also an easy way to do this. Just use :

pio lib install <repository#tag> 

// Install development version of WifiManager library
pio lib install

7. If you use Arduino before it’s possible that you used some of it’s constants. So if your sketch compiles, but it does not runs like expected try to add this include line at the beginning

#include <Arduino.h>
Including Arduino.h at the beginning of the sketch

As a footer note I must make clear that it takes some time to get accustomed to the new IDE. But it comes with a great benefit as it shows you much better C++ warnings, it’s prettier to use, and has the advantage that you can Ctrl+Click and navigate between different classes. Something that it was not possible to do with my old IDE. And the most beautiful update is that all libraries are in a single place per Project, like it should be, leaving you a clear idea of how much code and dependencies you are adding into your sketch.

In FS2 project porting it to the ESP8266 Wemos board this happened like a breeze. And it was just the fact of upgrading my code to use OneButton library. adding the include Arduino.h and that is. After uploading SPIFFS data and the new code, the camera was ready to be used. Now it’s not always that easy. trying to compile the same code to an Heltec ESP32 board, I got SPI communication issues with the camera and I’m still fighting with it.

UPDATE: I found what is going on here, and it’s that there are some problems with my sketch that uses I2C and wire library to comunicate with the Camera on the Heltec ESP32 environment. Error message is:
i2cCheckLineState(): Bus Invalid State, TwoWire() Can’t init. I solved it updating the platformio.ini configuration file to use:
board = lolin_d32
So using this board it compiles and works correctly. No idea why it does not using heltec_wifi_lora_32 I will have to research more.

Additional links of interest:

Source filter: src_filter
This option allows to specify which source files should be included/excluded from build process. It could be useful to keep the same core for ESP8266 and ESP32 but including different files to support both. So far I’ve been using 2 different branches something that is hard to maintain for obvious reasons.

Library dependencies: lib_deps declaration in platformio.ini
Like composer for PHP, this IDE offers a way to declarate your libs in the ini file. To check how a professional software for 3D-printing does take a look in Marlin configuration file. This is a very important point to keep in mind since after the lib_deps list is correctly added and tested, people testing your code just need to hit “build” to download them, saving a huge amount of time. This are FS2 library dependencies.

FS2 Camera project

If you are interested to build your own WiFi Camera for around 40€ of components and maybe 5€ of 3D-printed case, then check this project on github:

I’m giving out in december ten free 3D-printed cases, if you are interested on getting one and putting together a WIFi Camera please choose between Black PLA, black PETG or RED transparent and comment in this post. You can send me the address later per private message or in twitter. Thanks for your interest!

FS2 camera from Blender to production

In this entry, I wanted to document what is the process of making one of this cameras, starting from the 3D – model to the end product where you turn it on and connects to WiFi ready to take pictures.

After removing the support and sanding the round columns the first thing is to connect the front and back case together and see that they fit correctly. Usually, they do but PET is a tricky plastic to print and the end termination is a bit rougher than with PLA so it requires some post-production work. As an advantage, this plastic is stronger than PLA, and will stand a crash much better since it’s more elastic and resistant. I would say the best termination and strength balance would be to print this in ABS but I dislike the smokes and the fact that is also very difficult to print at home.

When this step is ready then it’s the time to heat up the soldier and prepare the ON/off switch and the shutter button. Then there are 8 cables more that go from the Arducam (2 or 5 mega version) to the Wemos D1, that is the responsible of uploading the picture to the cloud. This is a prototype for myself so it looks a bit messy but shows how it is at this stage:

3 pair of cables from the left to the right: Battery, ON/off and shutter button

Then comes the reality shock moment that is to connect the Wemos ESP8266 through USB to the computer and upload the program that will do the magic of receiving the JPEG image from Arducam and upload it to a php API endpoint. Usually, at this point there is something that needs to be corrected, but either nothing works or all is fine and dandy. I open the mobile hotspot and turn on the camera. See if connects, try to take a picture, preview it on the PHP-gallery.  Try to test timelapse mode, see it works, and that’s pretty much it. A new camera is ready to be delivered.

FS2 WiFi camera

E-Paper driver to make your electronics smaller

Got from Waveshare some of this E-Paper ESP8266 driver boards:
e-paper esp8266 driver-board

I’m trying to make the electronics of my displays as small as possible and to avoid the wire-chaos inside the case with the goal of having more space for the battery. This will basically spare the need of the driver HAT and additional cables, something that is still present in my first prototype:

A bit messy uh ?

The only issue I see and I’m still sorting out with Waveshare is that the cable is not coming with the RAW display. But I think it will be not a show-stopper.

E-Paper ESP8266 driver board example developed by Waveshare

  • Supports Floyd-Steinberg dithering algorithm, more color combinations, better shadow rendering for the original image
  • Supports popular image formats: BMP, JPEG, GIF, PNG, etc.


  • WiFi protocol: 802.11b/g/n
  • Interface: 3-wire SPI, 4-wire SPI (default)
  • Operating voltage: 5V
  • Operating current: 50mA ~ 100mA
  • Outline dimension: 29.57mm x 48.26mm
  • Mounting holes size: 2.9mm

When I find the time will post about the first tests and specially about consumption. Currently I’m using a 7.5 B/w only display with a 1200mA battery for our office. My only wish is that Waveshare electronics makes bigger E-paper displays so we can make more visible charts for our clients (10.3″ or 13 inches)

UPDATE from Waveshare

The sales people replied me, the cable is included when you buy the driver, it’s on Package contents Tab on Waveshare website:

  1. e-Paper ESP8266 Driver Board x1
  2. e-Paper Adapter x1
  3. 24PIN FFC x1
    2+3-> 24 pins cable is included.
    So that’s it, you just need this driver, and to buy one RAW display. So it will run using a core of only 3 elements: Driver, Cable and E-paper display

E-Paper driver board specifications