I am trying to use Raspberry Pi pico to sample signal of frequency of around 24 KHz and store the values in an array. From Nyquist criteria, the sampling frequency should be 48 KHz. But I can properly sample signals of frequency 2 KHz. We tried overclocking to 270 MHz, but it improved from 2 KHz to 5 KHz only. Any suggestions on how should I do it? According to internet resources How to use ADC in raspberry pi pico , the sampling frequency is 500 KS/s. Hence, my requirement should easily be met.

  • I can properly sample signals of frequency 2 KHz ... how did you measure this?
    – jsotola
    Jun 10, 2023 at 20:56
  • I used a signal generator to give a sinusoidal wave as input and sampled and plotted it in real time in Thonny IDE. I could see a sinusoidal wave as output for lower frequencies.
    – Nimesh
    Jun 12, 2023 at 5:11

2 Answers 2


Take a look at this link: https://iosoft.blog/2021/10/26/pico-adc-dma/ The author pulls date from the ADC using DMA and includes a method to change the sample rate. I have tested the code and can verify that it works.

Jerry Wasinger Founder, Pi-Plates


If you want to do more than a one-off capture and process it then you are likely to need more than one array to hold the data to allow concurrent capture and processing. As per the other answer, DMA is the way to go if you want jitter-free continuous capture at predictable rates, 2-5ksps sounds like a for loop in an interpreted language, that's going to be a struggle to get low-jitter captures.

I like using MicroPython/CircuitPython but depending on what you want to do with the data it may be time to switch to C++ to give you more control over what the hardware is up to and better performance particularly around the absence of an FPU on the M0-based RP2040. Having said that ulab may be an option.

This is a classic ping-pong approach using two buffers and the RP2040's DMA chaining https://github.com/zapta/simple_stepper_motor_analyzer/blob/main/platformio/src/acquisition/adc_dma.cpp - this happens to alternately read from two ADCs, useful for stereo audio work but the two will not perfectly be in phase due to the in sequence reads.

This is a well written C++ example of having dma from ADC GPIO26 at audio rates into a ring buffer https://github.com/iwatake2222/pico-work/blob/master/pj_adc_fft/AdcBuffer.cpp

BTW, I'm currently experimenting with this and there's a conflict with WiFi/Bluetooth that I don't so far understand. Bear that in mind if you're on a Pi Pico W.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.