# Raspberry Pi 3 SPI speed and ADC sampling rate

I have been working on a project where I am collecting data from an AD8232 ECG sensor in my Raspberry Pi 3.

The raw signal is so distorted and I am guessing I may have an issue with SPI speed and sampling frequency set up. While testing, I actually checked SPI speed from 2 kHz to 20 MHz. The sampling rate is 200 Hz. I am not getting how to fix this.

Anyone can suggest what may be a possible issue and fixes? FYI, I need a sampling rate of 200 Hz. I am using MCP3008 with my Pi as an ADC converter as the sensor is an analog sensor.

Increasing priority with nice can improve things, but it may not be enough. Consider using a dedicated unit (Arduino?) where you have full control over timing for acquisition, and transfer the properly acquired data to RPi or a laptop for analysis.
Another (unrelated) approach to noise reduction is oversampling: if you can get 2 kS/s instead of 0.2, and the noise is uncorrelated with the signal, averaging N samples will reduce the noise by $$\\sqrt(N)\$$.