ESP32: Use Arduino or ESP-IDF?

Kazuya91
Posts: 27
Joined: Wed Aug 23, 2017 11:33 am

ESP32: Use Arduino or ESP-IDF?

Postby Kazuya91 » Thu May 10, 2018 5:28 pm

Hello community,

I was wondering if i should use the official ESP-IDF or Arduino for my project...

First the hardware:
WeMos Lolin32
DS3231 RTC
MAX17043 Fuel Gauge

My Plan:
I want to use an external RTC to wake the ESP32 for a specific date and time. Are external RTCs and their wakeups supported by Arduino? Also i want to use i2c communcation for the MAX17043 Module which tells me how much battery charge is left. The modules have libraries for Arduino but i am not sure if my project will work on Arduino since everything isnt supported yet. Also I want to clock the ESP32 down to 80MHz all the time, since I dont need the speed. Can i adjust the hardware from the ESP32 with Arduino? In the ESP-IDF i just do an "make menuconfig" and a menu appears...

I really need some advices. Thank you in advance!

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: ESP32: Use Arduino or ESP-IDF?

Postby kolban » Thu May 10, 2018 10:32 pm

The discussion on using Arduino APIs vs native ESP-IDF APIs is liable to open up a "red vs blue" discussion. For me, the answer falls to two major concepts:

1. Is there a library I want to use that has been written for the Arduino?
2. Do I desire to run this application on an MCU other than the ESP32?

If the answer to either of the above are true, then for me, the Arduino API is very much a contender.

If both of the above are false, then, for me personally, I would design against the ESP-IDF directly. I say that, because I have invested time studying the ESP-IDF APIs and have a "comfort" level there. If a chap had exclusively studied Arduino APIs and knew them inside and out, then one would have to weigh the cost/challenge of studying ESP-IDF.

The benefit of ESP-IDF (over Arduino APIs) is that the ESP-IDF is native to the ESP32 (by definition). It is the API (short of register poking) that will give you the highest fidelity against the ESP32 device itself. There are capabilities available in ESP-IDF that aren't (yet?) present in mapped Arduino APIs. They could quite easily be mapped by a programmer but that then implies one already has an ESP-IDF skill level.

Also realize that these are not necessarily exclusive options. The Arduino APIs can be leveraged in a native ESP-IDF application by building the app with Arduino as a component.

I am ignoring the Arduino IDE and build/flash story in this story.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Kazuya91
Posts: 27
Joined: Wed Aug 23, 2017 11:33 am

Re: ESP32: Use Arduino or ESP-IDF?

Postby Kazuya91 » Thu May 10, 2018 11:39 pm

kolban wrote:The discussion on using Arduino APIs vs native ESP-IDF APIs is liable to open up a "red vs blue" discussion. For me, the answer falls to two major concepts:

1. Is there a library I want to use that has been written for the Arduino?
2. Do I desire to run this application on an MCU other than the ESP32?

Hello Neil,
Both, the DS3231 and the MAX17043 already have libraries for the Arduino. I dont want to use the code for other MCUs. Do you know if an external RTC like the DS3231 can be used in Arduino as a wakeup source for the Deep Sleep of the ESP32?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: ESP32: Use Arduino or ESP-IDF?

Postby kolban » Fri May 11, 2018 1:43 am

A quick look at the datasheet here:

https://datasheets.maximintegrated.com/en/ds/DS3231.pdf

Seems to show that Pin 3 of the DS3231 is an interrupt pin which at first glance has a mode that can be configured to toggle when an "alarm" value is reached. I'm going to believe that a signal change on the output pin can be used as a trigger to wake the ESP32 out of some deep sleep mode.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

debojitk
Posts: 1
Joined: Thu Jul 26, 2018 7:48 pm

Re: ESP32: Use Arduino or ESP-IDF?

Postby debojitk » Thu Jul 26, 2018 7:56 pm

Hi,

I have worked with esp8266 but using Arduino library on Eclipse. Now I plan to start with ESP32. Actually I am quite comfortable with Arduino library. As I understand ESP IDF is more powerful than Arduino library. So can I work in arduino environment and access ESP IDF apis whenever needed from that environment?
One more specific question: Can I use multi-threaded programming using Arduino library, means running two threads that will run in parallel.

Thanks,
Debojit

ESP_Sprite
Posts: 9769
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32: Use Arduino or ESP-IDF?

Postby ESP_Sprite » Fri Jul 27, 2018 1:16 am

The ESP32 Arduino SDK is built on top of ESP-IDF, so you should be able to use most ESP-IDF functionality as is. This includes multitasking; be aware that as far as I am aware Arduino doesn't have specific support for this so you have to fall back to the FreeRTOS primitives to do this. I know that multiple people have tutorials on how to do this, however.

juuisle
Posts: 3
Joined: Sun May 10, 2020 5:24 pm

Re: ESP32: Use Arduino or ESP-IDF?

Postby juuisle » Sun May 10, 2020 5:42 pm

Hello everyone,

I am looking for a really convinced reason why ESP-IDF is a good choice for professional reason. The reason I use ESP-IDF is that it comes with the freeRTOS, which I am comfortable with. However, I don't know much about Arduino, it looks ok to me, except it works like magic boxs. Could anyone please teach me some examples of why ESP-IDF is better, for professional reasons?

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32: Use Arduino or ESP-IDF?

Postby chegewara » Mon May 11, 2020 7:14 pm

Flash encryption and secured boot. You dont have it out of the box in arduino.

username
Posts: 539
Joined: Thu May 03, 2018 1:18 pm

Re: ESP32: Use Arduino or ESP-IDF?

Postby username » Tue May 12, 2020 2:25 am

You dont get all the extra flexibility from menuconfig to do enhancements and fine tuning.

ESP_Sprite
Posts: 9769
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32: Use Arduino or ESP-IDF?

Postby ESP_Sprite » Tue May 12, 2020 7:53 am

Also, note it's not an exclusive choice. You can use most ESP-IDF features from Arduino and you can import the Arduino library into ESP-IDF. (There still are some small downsides to both solutions: you can't use the Arduino IDE in ESP-IDF and you can't use Menuconfig from Arduino, as stated above.)

Who is online

Users browsing this forum: No registered users and 58 guests