在 DSP 中,术语“滤波器”通常是指对连续信号中的频率分量进行放大或衰减(即“降低”)。这通常使用快速傅里叶变换 (FFT) 来完成。FFT 从在给定时间长度内记录的信号开始(数据在所谓的“时域”中)并将这些值转换为所谓的“频域”,其中结果表示一系列信号的强度频率“箱”的范围从 0 Hz 到采样率(在您的情况下为 10 Hz)。因此,作为一个粗略的例子,一秒钟的数据(10 个样本)的 FFT 将告诉您信号在 0-2 Hz、2-4 Hz、4-6 Hz、6-8 Hz 和8-10赫兹。
要“过滤”这些数据,您将增加或减少任何或所有这些信号强度值,然后执行反向 FFT 将这些值转换回时域信号。因此,例如,假设您想对转换后的数据进行低通滤波器,其中截止频率为 6 Hz(换句话说,您想去除信号中高于 6 Hz 的任何频率分量)。您将以编程方式将 6-8 Hz 值设置为零并将 8-10 Hz 值设置为 0,然后执行反向 FFT。
I mention all this because it doesn't sound like "filtering" is really what you want to do here. I think you just want to display the current value of your sensor, but you want to smooth out the results so that it doesn't respond excessively to transient fluctuations in the sensor's measured value. The best way to do this is with a simple running average, possibly with the more recent values weighted more heavily than older values.
A running average is very easy to program (much easier than FFT, trust me) by storing a collection of the most recent measurements. You mention that your app only stores values that are different from the prior value. Assuming you also store the time at which each value is recorded, it should be easy for your running average code to fill in the "missing values" by using the recorded prior values.