Esp32 framework library updates

I have been living under a rock for a few months and happily coding away on esp32 for various things. Recently I was porting something to esp32 -s2 which is a childs project which uses the ADC for a basic spectrum analyser. So accuracy etc not really an issue, but sample rate obviously matters and the S2 was quite a bit slower than the esp32.

I happened upon ADC — Arduino-ESP32 2.0.14 documentation

Which describes espresifs arduino framework ADC api. In particular analogContinuous() together with an example.

The question is, is this very new and thus not yet generally available? I can’t find references to this functiuon or any pages on the internet with the words esp32 and analogContinuous on the same page except that page and the github repo.

I guess what I’m really asking is, if someone knows how the versions work is this available or am I just missing a header file?

PlatformIO is officially on Arduino-ESP32 2.0.11, like the latest release notes say.

If the problem is the version of the framework, you can explicitly upgrade to 2.0.14 by using a platform_packages directive in the platformio.ini, like this post says.

Experimental upgrade to Arduino-ESP32 3.x is also possible, as outlined here.

It didn’t fix it using 2.0.14 so I am guessing it is just very new. Looking at the repo I see that esp32-hal-adc.h was updated October 6th and there are the functions I was looking for. I don’t quite know my way around well enough to know if that is in 2.0.14 tag or in the newer 3 tags. So their documentation doesn’t match the actual build and looks like its ahead- usually documentation is later if at all!

So, this is good, the IDF contains DMA based sampling functions and Arduino did need them so it will be good. I may look to see if I can bodge 3.0 in and see if I can give it a whirl. All I really wanted was a way to sample 512 samples at 32khz without massive amounts of jitter and I ended up down this rabbit hole. I didn’t want any extra hardware because I’m trying to upgrade something that already exists and I know the chip is capable.

2.0.14 does not have it.

3.0.0 (alpha) does have it.

So with just a change in platform as I’ve linked above, you should be able to get 3.x.

since you got back to me so quickly I have set that off and its grabbing the bits it needs, then I will do actual work that I’m supposed to be doing but then I will check back and let you know if it works - which I guess we already can see by the changes its probably going to.

I can tell you that it works.

For anyone finding this post in future, this bit of code isn’t that useful. Whilst it does do DMA sampling internally its just used to create an average of multiple samples and doesn’t provide a method to access the samples. Its very tightly coupled to take a bunch of pins and maintain an average ADC value on them and that is all so its not very flexible. To use for creating an array of samples at a given sample rate it would require heavy modification and a lot of dodgy ram re-allocation which is destined for memory fragmentation or leaking. Maybe it can be used as a starting point between IDF and Arduino but thats for someone smarter than me.