So PlatformIO and Arduino yes, ESP-IDF no?

The message I’ve gotten has come down to this:
ESP-IDF is difficult, and it’s really limited. If I were to get good at it, I’d still be stuck without library support. So it looks like it’s a high aspiration, but it’s maybe a fool’s errand for most people who like me come from Arduino, who want to rig up a bunch of gizmos together and make them blink.

I thought that since ESP-IDF ends up in VSCode and PIO anyway, it must be better.

What I really want to do is use the ESP Upload tool to upload a handful of programs to the ESP32. I want to run a menu program on the Pro processor and use the App processor to run programs selected from that menu. But ESP-IDF is not necessary for that.

1 Like

I’ve just tried this:

  • go to the PIO home page
  • select New Project
  • Give it a name and (in my case) selected ESP32_WROVER_B
  • Selected the ESP_IDF library and started the build
  • In the “main.c” edited the template to be:
    #include <stdio.h>
    void app_main()
    {
    printf(“Hello World\n”);
    }
  • built the project and downloaded it
  • started the serial monitor at 115200 baud
  • I did need to reset the board as the serial monitor didn’t come up until after the code had run to completion
  • saw the text output by the boot and then saw my “Hello World”
    From this I conclude that the basic setup works. I’ve previously had issues with the BLE modules in the ESP-IDF library but that is another story.
    Susan
3 Likes

I would agree in principle - ESP-IDF is ‘difficult’ in the sense that it is “not as easy as as Arduino”. Primarily because (I believe) it is not so popular, and is device specific. Arduino is much more transferable, and you can use many different boards with that framework. You can often use the same code on a Arduino Uno, STM32F103, or an ESP8266 - the different board support packages (platforms) work the rest out for you.

Additionally, there is a LOT of example code for Arduino, and a lot of libraries. Not so much for the ESP-IDF. But it does exist. It really depends what you are trying to do. If it’s simple, you don’t need the best possible performance, or don’t want to have to learn MCU specific code, stick with Arduino. You can apparently use the ESP-IDF with Arduino, and effectively get the best of both, but I don’t know anything more than that.

The ESP-IDF will be better than Arduino. But better does not mean simple. :wink:

1 Like

Arduino code doesn’t necessarily pass the adult test. It’s not strict C++. The preprocessor does extra stuff. I am re-learning how to declare modules now (haven’t gotten anywhere yet), because the standard methods in Arduino don’t get through the compiler / verification.

ESP-IDF requires a lot of background. I don’t know the words to type, and the computer becomes a blacker box in C prompt. So I’m building the economics of capacity into my assessment.

But I’m looking at this as a bankruptcy restructuring. I furloughed the part of my brain that wants to do ESP while I learn proper coding. And then I have to learn conventions. And when I can cause a good binary file to be created, I’ll be able to upload it to the ESP-32.
And hopefully by that time, I’ll know how to work bluetooth.

Thank you!

2 Likes

If you are doing hobby projects you will probably be fine with Arduino. The instant you have hard deadlines or need threads Arduino becomes useless due to its lack of RTOS support

1 Like

RTOS is being used in Arduino.

1 Like

The biggest difference is memory. In Arduino, it never comes up, and you never learn that the language is all about memory.
Learning that a variable is a named space in memory, everything (lots of things) snapped into place.

1 Like

Arduino is c++. There is no special preprocessor.

You can use both the esp-idf apis and the arduino libraries and apis. Arduino is indeed not multi-threaded so if you are using multiple threads you have to provide your own locking. The esp-idf api has locks that meet that need.

When I switched from Arduino to PIO, none of my Arduino-written files worked. They all had to be edited for stricter C++.

Of course, I had edited most of my Arduino sketches to add doodads. But I never wrote any of my own functions from scratch. They were all pulled from published examples and tutorials.

I am going to do my development in Arduino framework to get the best binary files I can get. Then I want to use the upload tool to put a list of programs on it.

Libraries are next on my C++ learning list. I want to make my own libraries, one for each realm of projects. Sensors, motorized stuff, BLE, etc.

Unfortunately, this is not the case. The Arduino IDE uses a preprocessor. Arduino sketches (.ino files) are non-standard C++.

The preprocessor does two things I am aware of:

  1. It adds #include <Arduino.h> to the top.

  2. It adds a function declaration at the top for each function definition it finds. This allows the use of the function before its definition. In regular C++, you at least need to declare it before you can use it.

2 Likes

This and memory are the two irks I have with Arduino, besides the fact that their apps simply stopped working here.

If this was the case, the Arduino folks wouldn’t need to have written and maintain their own pre-processor, now would they? :laughing:

An Arduino sketch differs from a standard C program in that it misses a main (provided by the Arduino core), function prototypes are not mandatory, and libraries inclusion is automagic (you just have to #include them). This tool generates function prototypes and gathers library paths, providing gcc with all the needed -I params.

source: GitHub - arduino/arduino-builder: A command line tool for compiling Arduino sketches

2 Likes

This exactly has been my thought for the past months. I would really like to learn how to program the Esp32 in its purest Form (ESP-IDF), to learn how to go deeper in the Hardware and learn FreeRTOS. But then what is the point in learning all that when there is a huge Lack of libraries for the esp-idf. Even to find the most trivial components you only find buggy examples in github. Servos, Oleds, LCDs all have better working libraries for the arduino framework. Besides (and perhaps not so much of an issue for others) most libraries are written in c. The Implementations of this libraries are full of structs and passing references to functions. Personally I prefer a c++ Implementation. I would rather Keep an organized structure of my project using classes. But forget about that if you are using esp idf.

1 Like

Hi to all!

I worked on a project written in Arduino and developed it for 18 months. At the beginning, everything was just OK. Do you know what happens then? Just in times of release, we found that Arduino is not well compatible with Flash Encryption. Bingo!

Investigating framework = arduino, espidf and trying to work with recently added pio run -t menuconfig for the aim of flash encryption had no success!

Right now, I’m converting the whole project to a framework = espidf version!

Now you can decide based on your application:

  1. Student work / Test project / Personal project: Enjoy Arduino Libs!
  2. Mass product project: Use ESP-IDF!

Bests!