Skip to content
Discussion options

You must be logged in to vote

On other ports (e.g. STM32) we support adc.read_timed which allows the ADC to be sampled at a fixed rate.

Unfortunately this is not (yet) supported on ESP32.

If you want this to run in the background while the code does other things, your best bet is to use a timer and read from the ADC in the interrupt handler. I recommend pre-allocating the output buffer so that the handler doesn't have to do any allocations. Unfortunately the sample rate will not be terrible high.

If you just want to sample as fast as possible, then calling ADC.read in a loop (optionally with time.sleep_us), but there will be quite a lot of jitter in the sampling interval.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@saraverbeecke
Comment options

Answer selected by saraverbeecke
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
ESP32
Labels
None yet
3 participants