software low pass filter debug help

I am not sure where current_data[] in setup came from.

You loop through every element when getting rid of the old one, but you access data[i+1] which might access an element past the end of the array.

It might be better to use something like avg_val = avg_val* (1-avg_factor)/avg_factor + new_val/avg_factor