For a number of Arduino projects, I've used the online filter design utility here: https://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html. It will design the filter and produce a C code implementation which can be copied over to an Arduino sketch with some modification.

For this instance the filter design parameters might be (1) Butterworth/Lowpass, (3) Filter order: 1 (or 2), (4) Sample rate: 100, (5) Corner frequency 1: 5, which produces the code:

```
#define NZEROS 1
#define NPOLES 1
#define GAIN 7.313751515e+00
static float xv[NZEROS+1], yv[NPOLES+1];
static void filterloop()
{ for (;;)
{ xv[0] = xv[1];
xv[1] = next input value / GAIN;
yv[0] = yv[1];
yv[1] = (xv[0] + xv[1])
+ ( 0.7265425280 * yv[0]);
next output value = yv[1];
}
}
```

Note that your sample rate is probably not 100 per second, but for digital filter design the ratio of the corner frequency to the sample rate is all that matters. From the plot in the original post, it looks like the nominal frequency is about 1 cycle per 100 samples, so this filter is designed to pass frequencies less than 5 cycles per 100 samples.

Ported to Arduino as a function, this would look something like:

```
#define NZEROS 1
#define NPOLES 1
#define GAIN 7.313751515e+00
static float xv[NZEROS+1], yv[NPOLES+1];
static int filterloop(int xIn) {
xv[0] = xv[1];
xv[1] = xIn * (1 / GAIN) ;
yv[0] = yv[1];
yv[1] = (xv[0] + xv[1]) + ( 0.7265425280 * yv[0]);
return int(yv[1]) ;
}
```

It would be called for each input sample in the processing loop.

```
. . .
int x = analogRead(A0) ;
long int y = filterloop(x) ;
. . .
```

Where "x" is your raw reading and "y" is the low pass filtered version of the same.

The theory behind all this is non-trivial, but generating the code, given this tool is pretty straightforward.