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.

Raw data signal


Raspberry Pi is a poor choice for precise sampling unless you get a hard realtime system (like QNX) to run on it. If you're on Linux, you're running several dozen of tasks in parallel on only 4 CPU cores, and the task that reads the data is not even the highest priority, so there's very little confidence in the fact that your sampling rate is really 200Hz.

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)\$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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