PlatformIO Community

ESP8266 + STM32F4 - Advice is needed before I waste more time!


I found it. It’s working now even without any modification to PATH!


When starting a “New Terminal” from drop-down menu, you will get the CMD of the system. In order to get access to a PIO Terminal, I had to go to PlatformIO (botton on the left) > Miscellaneous > New Terminal



Do I have to execute: pio init --ide=vscode form within both folders? And Do I have to import both of them in the IDE?


Exactly, because they’re separate projects


Yes, I checked the files and they look two distinct projects with their own dependencies. However, I still don’t understand how both are going to be compiled in PIO to generate a single BIN file to flash the ESP8266. I guess I missed something here. Or maybe stm32 code has to be flashed to the STM32, and the ESP8266 code has to be flashed to the ESP8266. PIO only used as a single IDE and toolchain for both domains. That’s it!


It’s two firmwares, one for the STM32 and one for the ESP8266. The esp8266 contains the project which will generate the firmware.elf/ bin for the ESP8266. Once imported in VSCode you can compile and upload the project as usual. Can also be done from the shell using pio run (build) and pio run -t upload (build & upload)

Multiple workspaces setup: Working with multiple projects in VSCode


Yep, I got it. Thank you very much. Luckily enough, I’ve got the DH11 sensor here so I’m ready to do testing!


The STM32 code was written for a STM32F1 series MCU, so you’ll have to do some porting or first setup the ESP8266 part and send it some dummy values via serial according to the protocol.


By the way, what is the best and most appropriate way to import sources’ folders into the IDE?


That depends very much on what code it is; src for firmware-specific stuff, lib for general reusable library code. May need additional -I build flags so that it finds all the include paths. Headers in the include/ folder are always included though.


Porting for STM32 should be fine for me. Thank you very much for the great availability and super fast replies!


From PIO Home, I used “Open Project” then I have been able to add all folders into the IDE. Please take a look here:

However, as you can see, the value for platform was “arduino”. Do I have to change that or it doesn’t have any effect on the build of project? I have also changed the baud rate.


It seems the more I’m trying to escape that Arduino thing, the more it’s chasing me. Not because of anything, but because I’m more inclined to C. Well, I guess it’s still much easier from learning Lua or another language.

So, the ESP8266 firmware example you provided was built around the Arduino Platform? But how the ESP8266 executes binaries created for Arduino platform?

For custom firmwares out there like ESpurna, Easy_ESP, ESP-Link, do you think all of them use the same Arduino Platform to build the firmware? What about the SDK from Espressif? For someone totally new to this IOT thing, like myself, what would be the best template project, platform, or whatever to learn from when developing a custom firmware?


“Arduino” is a framework. It’s written in plain C and C++. Specifically the Arduino framework port for the ESP8266 used is Firmwares are built by compiling the framework code with gcc or g++ (pio run -v to see the compiler commands). ESP-Link uses the Espressif SDK 1.5.4 (here).


Thank you again for the follow up. Well, I didn’t know anything about the Arduino Platform before and I believe it’s been away from my toolchain for quite a bit since I develop my embedded projects under Keil’s uVision and ARM compiler. I know this is not a place to learn more about the Arduino, but if you don’t mind me asking one more question related to the Arduino, do you mean the “Arduino” is merely a library written in C/C++ without any specific hardware dependencies, and it can be incorporated with any embedded project built with GCC-based toolchain?


There are hardware-dependent implementation parts and hardware-independent parts. For example, the APIs are platform independent (every Arduino core has a digitalWrite(byte pin, byte state) function), but the implementation thereof is hardware dependent. E.g., see the Atmel AVR Arduino core vs the ESP8266 core. And yes, the Arduino core can be compiled with any gcc/g++ based toolchain; This is exactly what PlatformIO does when you build a project with this framework.


Cool, I got it now!

For beginners in IOT/ESP8266, do you suggest working under Arduino Platform or Espressif’s SDKs?


Definitely Arduino because of the wealth of libraries available and the community. Everything done in Arduino will still be perfectly possible with Espressif’s SDKs, alas with more code to write yourself if the libraries aren’t there. However it seems that Arduino kinda has the reputation of being for beginners / beginners project only, which I don’t really share. It’s just a framework, it depends on how you use it in your application.


I totally agree. I had the same thought, but absolutely, C++ has nothing to do with beginners!


I think everything is clear now to begin with PlatformIO. Should I post new questions/issues as they arise here or start a new thread?