how to change the ESP-32 ADC sampling rate?

Matheus_alvez1515
Posts: 2
Joined: Wed May 12, 2021 3:34 pm

how to change the ESP-32 ADC sampling rate?

Postby Matheus_alvez1515 » Wed May 12, 2021 3:48 pm

I have a project, in which I need to acquire a 4096 samples of a 60 Hz frequency signal. Using the analogRead () function, with a maximum of 3 signal cycles, I would like to know how to increase the number of cycles for the 4096 samples of the 60 Hz frequency signal without changing the resolution, changing only the sampling rate.

ns1668
Posts: 50
Joined: Tue Mar 16, 2021 2:00 pm

Re: how to change the ESP-32 ADC sampling rate?

Postby ns1668 » Fri May 21, 2021 9:33 am

So you want to increase the sampling rate of analogRead(), can you post some code so we can see what you are doing currently?

lbernstone
Posts: 827
Joined: Mon Jul 22, 2019 3:20 pm

Re: how to change the ESP-32 ADC sampling rate?

Postby lbernstone » Fri May 21, 2021 2:35 pm

arduino-esp32 has an operating system running, which will use some cpu cycles and make any sort of timing technique fail. I would suggest you use a peripheral (pulse counter or rmt) to capture your data without the cpu. If you are trying to do RMS or something where the timing is not as critical as max/min, you can use the I2S to capture data from ADC. https://github.com/espressif/arduino-es ... eq_ADC.ino

Matheus_alvez1515
Posts: 2
Joined: Wed May 12, 2021 3:34 pm

Re: how to change the ESP-32 ADC sampling rate?

Postby Matheus_alvez1515 » Fri May 28, 2021 8:25 pm

using the function analogSetCycles (255); I achieved a gain in the number of cycles, however, I would like to obtain a greater gain of cycles, however, the function has a maximum parameter of 255, I tried to use the function analogSetSamples (2); however, I got a distortion in the values ​​read, so, I wanted an alternative to increase the number of cycles, I followed the image of the normal result and with the increase of cycles:

image of the normal number of ESP-32 cycles:
https://mega.nz/file/3i5BCKhY#8mcg6UbON ... fQ8vtqqhjc

image with the analogSetCycles () function; implemented:
https://mega.nz/file/f24z3SBA#Qv4JdxhAk ... AN7njYVYcs

Who is online

Users browsing this forum: No registered users and 80 guests