Beginner ESP32 questions

borgdrone7
Posts: 3
Joined: Thu Oct 31, 2019 6:23 pm

Beginner ESP32 questions

Postby borgdrone7 » Sun Sep 13, 2020 8:55 pm

Hi,

I was using ESP 8266 and coding on it was very straight forward and there were examples all over the place. Now I wanted to switch to ESP32 but I noticed there is IDF way of coding and "Arduino" way of coding. For example I wanted to start with simple bluetooth connection with Android to send text messages back and forth.
When searching for examples on the net I realized there is "Arduino" way of doing it which is 10 lines of code and there are examples all over place for it. Another is IDF way of doing it which lack documentation and only example I could find is on IDF forums and simple example is posted by one guy and the example is not 10 lines, it is 10 pages.
Why is this happening with ESP32. I realized that if we want to use all the features of the ESP32 we need to use IDF as it has FreeRTOS to use both cores as we want, control all hardware features, etc. But issue I have with this is that there is no enough documentation as for example IDF docs don't even have a simple Bluetooth example (the ones in example folder are all some specific use cases and there is no simple example to get basic communication with phone).
If it that now all the code written in Arduino port for Esp32 we basically need to write from scratch and without proper community and docs?
I would like to really use all the features of ESP32 but I don't want to spend ages just to send/receive text message on bluetooth. I can imagine it is almost impossible to implement some projects I did on 8266 on ESP32 with IDF using dozen of sensors, touch screen display, etc.
I am writing all this as I am so confused that I am planning on moving to completely different microprocessor as I really don't see how ESP32 can be used easily. I hope I misunderstood something as I really liked 8266. I don't mind writing complex code (my 8266 projects had thousands of lines of code) but I don't want to spend 80% of time googling for simple stuff.
Can you please give me some advice?

Thanks

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

Re: Beginner ESP32 questions

Postby ESP_Sprite » Mon Sep 14, 2020 7:45 am

If it helps, you can mix and match Arduino and ESP-IDF code. The ESP32 Arduino environment is based on ESP-IDF, so all the APIs are available, and you can add Arduino as a component to ESP-IDF so you get access to all the things it can do.

abansal22
Posts: 51
Joined: Wed Apr 22, 2020 8:24 am

Re: Beginner ESP32 questions

Postby abansal22 » Mon Sep 14, 2020 5:18 pm

borgdrone7 wrote:
Sun Sep 13, 2020 8:55 pm
Hi,

I was using ESP 8266 and coding on it was very straight forward and there were examples all over the place. Now I wanted to switch to ESP32 but I noticed there is IDF way of coding and "Arduino" way of coding. For example I wanted to start with simple bluetooth connection with Android to send text messages back and forth.
When searching for examples on the net I realized there is "Arduino" way of doing it which is 10 lines of code and there are examples all over place for it. Another is IDF way of doing it which lack documentation and only example I could find is on IDF forums and simple example is posted by one guy and the example is not 10 lines, it is 10 pages.
Why is this happening with ESP32. I realized that if we want to use all the features of the ESP32 we need to use IDF as it has FreeRTOS to use both cores as we want, control all hardware features, etc. But issue I have with this is that there is no enough documentation as for example IDF docs don't even have a simple Bluetooth example (the ones in example folder are all some specific use cases and there is no simple example to get basic communication with phone).
If it that now all the code written in Arduino port for Esp32 we basically need to write from scratch and without proper community and docs?
I would like to really use all the features of ESP32 but I don't want to spend ages just to send/receive text message on bluetooth. I can imagine it is almost impossible to implement some projects I did on 8266 on ESP32 with IDF using dozen of sensors, touch screen display, etc.
I am writing all this as I am so confused that I am planning on moving to completely different microprocessor as I really don't see how ESP32 can be used easily. I hope I misunderstood something as I really liked 8266. I don't mind writing complex code (my 8266 projects had thousands of lines of code) but I don't want to spend 80% of time googling for simple stuff.
Can you please give me some advice?

Thanks
Sorry brother, i beg to differ. I started my project journey with esp32 with zero knowledge on Arduino or esp -idf. I never compiled a single program on any microcontroller on any platform. So I stated with esp32 on arduino. Within a month I was able to mix arduino code with esp idf. After a month or 2, I left the arduino completely. The reason that with Arduino framwork, you are not able to get the full functionality of esp32. There is the steep learning curve, but once you learn then you came to know the power of esp32.

Now coming to the point, about the bluetooth programming. I felt same as lost like you. I patiently read books on bluetooth low energy. From books I learn the concept like gap and gatt. Then I open the example and read them. I try to implement it by my own. Then i came to know how esp idf works. What are event. What is a callback function etc etc. My suggestion is try to implement previous projects on esp 32 using esp idf. Once you got familiar with the esp-idf, you can implement any project.

borgdrone7
Posts: 3
Joined: Thu Oct 31, 2019 6:23 pm

Re: Beginner ESP32 questions

Postby borgdrone7 » Sat Sep 26, 2020 1:23 pm

Thank you guys, as you told me I realized both can be mixed so it really makes everything good now. I am using freeRTOS tasks and Arduino at the same time and it all works great.
I still didn't come to the point where Arduino lib is limiting me but considering my previous project had 18k lines of code, I guess converting everything to IDF would be much work.
I decided to take it easy and start with Arduino, adding more and more direct IDF code as I progress or when I see that there is Arudino lib limitation of some kind.
Thank again for the help!

abansal22
Posts: 51
Joined: Wed Apr 22, 2020 8:24 am

Re: Beginner ESP32 questions

Postby abansal22 » Mon Sep 28, 2020 8:30 am

borgdrone7 wrote:
Sat Sep 26, 2020 1:23 pm
Thank you guys, as you told me I realized both can be mixed so it really makes everything good now. I am using freeRTOS tasks and Arduino at the same time and it all works great.
I still didn't come to the point where Arduino lib is limiting me but considering my previous project had 18k lines of code, I guess converting everything to IDF would be much work.
I decided to take it easy and start with Arduino, adding more and more direct IDF code as I progress or when I see that there is Arudino lib limitation of some kind.
Thank again for the help!
Currently I am working on the BLE Mesh. I didnt able to find the single library in Arduino framework. In my perception even the ble implementation is straight forward and simple for me in esp idf as compared to the Arduino library.

PeterR
Posts: 542
Joined: Mon Jun 04, 2018 2:47 pm

Re: Beginner ESP32 questions

Postby PeterR » Tue Sep 29, 2020 7:55 pm

Wait until you run out of stack ;) A cooperative Arduino loop has some advantages. Arduino libraries do no have to be round robin cooperative but they often are.
If I had my time again I would be inclined to look at putting all IP stuff under Arduino.
At the risk of hyjacking (oops, already did!) I do wonder what the IDF sense of having; HTTP, Websocket(?), mDNS, MQTT etc tasks all essentially servicing the same input/output. Buffer state must be maintained for each active socket after all.
HTTP as a task you can sort of get but the original lwip HTTP was cooporative state driven so you could pass back & poll/wait.
Guess its the orginal code base.
Just hope there is an OK router by the time I add Wifi! Maybe there is already.
Suppose in a few years & all that extra RAM....
& I also believe that IDF CAN should be fixed.

Who is online

Users browsing this forum: No registered users and 42 guests