How to assign smoothed data from serial into an array

Hello everyone. I am now using Arduino and Pulse Sensor to measure one’s heart rate. But now I do have a problem which makes me crazy.
I make a little change to the Smooth function in the library, which makes my data acceptable better. If I directly read it from the serial, and use Serial.println(average); it looks like a fairly good PPG signal series.


So I just want to store these data into an array, which can be used for later calculation. But the problem occurs. I write x[index] = average; just after the previous println sentence, which can, I assume, can guarantee that the value will be stored as soon as possible. However, when I finish storing the data. I find that what is printed from the x array is entirely different from the “acceptable” series I mentioned before.
I am really confused and wonder if anyone may answer me why. :sweat_smile:

The data read from x with for loop are like this:


I think it can be seen that there could be something related with period. But I want to make data in x as similar with serial data as possible. Can someone give me hints or suggestions?
Thanks a lot.

Post your code!

My code looks as shown here

Yes, I have posted it now.

Hello
do you think that the selected smooth function ist the correct function to flatten the noise of the raw data?

I am not so sure. But that’s modified from the code in the Arduino library. If I execute Serial. println(average); the result is just like the picture I posted in #1.
Do you have any advice?

Hello
Well you could use a search engine and search for AnalogSmooth.h

Do you mean the built-in example of IDE?

I meant the search engine for the world wide net.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.