In the rapidly evolving world of Internet of Things (IoT) devices, efficient signal processing is vital. Low-order Infinite Impulse Response (IIR) filters are popular choices due to their simplicity and computational efficiency. This article provides a comprehensive guide to designing these filters, covering theory, practical implementation, and best practices to enhance IoT device performance.

Understanding Low-Order IIR Filters

IIR filters are digital filters characterized by feedback, meaning their output depends on both the current and past inputs as well as past outputs. The term "low-order" typically refers to filters with one or two poles and one or two zeros — first-order or second-order filters. These filters are especially suitable for resource-constrained IoT devices because they require fewer multiply-accumulate operations and less memory than higher-order equivalents or Finite Impulse Response (FIR) filters of similar performance.

A first-order IIR filter has a transfer function of the form:

H(z) = (b0 + b1 * z-1) / (1 + a1 * z-1)

A second-order IIR filter (often called a biquad) has the form:

H(z) = (b0 + b1 * z-1 + b2 * z-2) / (1 + a1 * z-1 + a2 * z-2)

The coefficients b0, b1, b2 (for second-order) determine the zeros (feedforward), while a1, a2 determine the poles (feedback). Stability requires that all poles lie inside the unit circle in the z-plane, which is a critical consideration in fixed-point implementations.

Low-order IIR filters excel at tasks such as noise reduction, signal smoothing, and frequency selection. For example, a low-pass filter can remove high-frequency noise from a temperature sensor, while a high-pass filter can remove DC drift in an accelerometer signal. Their recursive nature allows sharp roll-off with very few coefficients, making them ideal for battery-powered devices where every microamp of current and every byte of memory counts.

Design Principles

Selecting the Filter Type

The choice of filter prototype (analog or digital) defines the trade-offs between passband flatness, stopband attenuation, and phase linearity. Common types include:

  • Butterworth: Provides a maximally flat passband with no ripple. It offers a monotonic roll-off but requires a higher order to achieve a given stopband attenuation compared to Chebyshev filters. Often preferred for sensor signal conditioning where amplitude accuracy is critical.
  • Chebyshev: Allows ripple in the passband (Type I) or stopband (Type II). In exchange for a small amount of passband ripple, Chebyshev filters deliver a sharper transition band for a given filter order. Useful when the stopband attenuation requirement dominates.
  • Bessel: Optimized for linear phase response (constant group delay), preserving the shape of the signal in the time domain. However, Bessel filters have a slower roll-off. Ideal for applications where overshoot and ringing must be minimized, such as in control loops or audio crossovers.
  • Elliptic (Cauer): Provides the steepest roll-off for a given order by allowing ripple in both passband and stopband. Rarely used for low-order IoT designs because the improved performance often requires floating-point precision and careful coefficient quantization.

For most low-order IoT applications, Butterworth and first-order Chebyshev filters provide a good balance. The filter design is often performed in the continuous-time s-domain using normalized prototype tables, then transformed to the discrete-time z-domain via the bilinear transform (with pre-warping) or impulse invariance method.

Key Design Parameters

  • Cutoff Frequency (fc): The frequency at which the filter's magnitude response drops by 3 dB (for low-pass/high-pass). Must be chosen relative to the sampling frequency (fs). For digital filters, the normalized frequency ranges from 0 to 0.5 times the sampling rate (Nyquist limit).
  • Filter Order (N): For low-order filters, N is 1 or 2. Higher orders can be realized by cascading multiple biquad sections, but the article focuses on single-section designs.
  • Passband Ripple and Stopband Attenuation: Critical for Chebyshev and Elliptic filters. A common passband ripple of 0.5 dB is acceptable in many IoT sensor applications. Stopband attenuation of 20–40 dB is often sufficient to remove typical noise sources.
  • Stability Margins: With fixed-point arithmetic, coefficient rounding can push poles outside the unit circle. Choose coefficient representations with enough bits (e.g., Q15 or Q31 format) and verify pole locations after quantization.

Trade-offs in Low-Order Design

The primary limitation of low-order IIR filters is the gradual roll-off (slope) and wider transition band compared to higher-order filters. A first-order low-pass filter attenuates only 20 dB per decade, whereas a second-order filter provides 40 dB per decade. For many IoT applications — such as filtering 50/60 Hz mains hum from a low-frequency sensor signal — a second-order filter often meets the requirements without overburdening the CPU. If sharper cutoffs are needed, designers must either accept higher filter order (and its computational cost) or transition to FIR filters, which can provide linear phase at the expense of memory.

The Design Process

Designing a low-order IIR filter for an IoT device involves several systematic steps. We illustrate a typical workflow using a second-order low-pass filter as the example.

Step 1: Define Specifications

Determine the passband edge frequency (fp), stopband edge frequency (fs), passband ripple (Ap), and stopband attenuation (As). For instance, we may want a low-pass filter with a 3-dB cutoff at 10 Hz, a stopband edge at 30 Hz with at least 20 dB attenuation, and a sampling rate of 100 Hz. The normalized digital frequencies are: ωp = 2π * (10/100) = 0.628 rad/sample, ωs = 2π * (30/100) = 1.885 rad/sample.

Step 2: Select Prototype and Order

Choose a filter type and find the required order using charts or formulas. For a Butterworth filter, the order N satisfies:

N ≥ log10( (100.1*As - 1) / (100.1*Ap - 1) ) / (2 * log10(ωs/ωp) )

In our example, with As=20 dB, Ap=3 dB (actually the reference is often the 3-dB point), a first-order Butterworth yields only about 7 dB at 30 Hz (20 dB/decade slope, ratio 3:1 gives ~11 dB attenuation, not enough). Second-order Butterworth gives 40 dB/decade, so at 30 Hz (3× cutoff) we get about 40*log10(3) ≈ 19 dB — nearly meeting 20 dB. Thus a second-order filter is appropriate.

Step 3: Determine Analog Prototype Poles and Zeros

For a second-order Butterworth low-pass, the normalized analog poles are at s = -0.7071 ± j0.7071 (for a cutoff of 1 rad/s). Use pre-warping if designing via bilinear transform: pre-warped critical frequency ωa = (2/T) * tan(ωd*T/2), where T = 1/fs. For fs=100 Hz, T=0.01 s. Pre-warped ωa = (2/0.01)*tan(1.885*0.01/2) ≈ 200*tan(0.009425) ≈ 200*0.009425 ≈ 1.885 rad/s (actually for low frequencies pre-warping is negligible). Many designers skip pre-warping for low-pass filters below 0.2 fs, but it's good practice.

Step 4: Bilinear Transform to Digital

Apply the substitution s = (2/T) * (z-1)/(z+1). For a second-order analog transfer function, algebraic manipulation yields the digital coefficients. Alternatively, use well-known formulas or design tables. For a Butterworth low-pass biquad with cutoff frequency ωc (digital), the coefficients can be computed as follows (standard form):

Let theta = ωc * T
Let Q = 0.7071 (for Butterworth)
Compute:
b0 = 1.0 / (1.0 + 2.0*sin(theta)/(2.0*Q) + sin(theta)^2 / Q^2)
b1 = 2.0 * b0
b2 = b0
a1 = 2.0 * b0 * (1.0 - sin(theta)^2 / Q^2)
a2 = b0 * (1.0 - 2.0*sin(theta)/(2.0*Q) + sin(theta)^2 / Q^2)

For our 10 Hz cutoff at 100 Hz sampling, theta = 0.628, sin(theta)=0.588. Plugging numbers yields coefficients that ensure stability. Tools like Analog Devices Filter Wizard or TI FilterPro automate this step.

Step 5: Quantize Coefficients for Fixed-Point

IoT microcontrollers often lack hardware floating-point units. Convert floating-point coefficients to fixed-point representation, such as Q15 format (16-bit signed with 15 fractional bits). Quantization introduces rounding error; check that the quantized coefficients do not cause instability. For a second-order filter, even 16-bit quantization is usually sufficient if the pole locations are not extremely close to the unit circle (i.e., low Q factors).

Step 6: Implement the Difference Equation

The direct-form I or II transposed structure is common for low-order IIR. The direct-form II transposed is recommended for reduced quantization noise and overflow prevention. The difference equation for a second-order filter is:

y[n] = b0*x[n] + b1*x[n-1] + b2*x[n-2] - a1*y[n-1] - a2*y[n-2]

All variables should be scaled appropriately to avoid overflow. For fixed-point, use saturation arithmetic or double-wide accumulators if available (e.g., 32-bit accumulator for 16-bit coefficients and data). Many microcontroller vendors provide optimized DSP libraries, such as ARM CMSIS-DSP, which include biquad filter functions with properly scaled coefficients.

Implementation in IoT Devices

Implementing low-order IIR filters on microcontrollers requires attention to memory layout, interrupt latency, and power consumption. Here are practical considerations:

Fixed-Point Arithmetic Strategies

Most ARM Cortex-M0/M4 microcontrollers support 32-bit operations. A common approach is to store coefficients and data as 16-bit signed integers in Q15 format (range -1.0 to 0.9999). Multiplications produce 32-bit results; for a biquad, use a double-accumulator then shift and saturate back to 16 bits. This avoids floating-point overhead and reduces power consumption. Libraries like CMSIS-DSP Biquad functions handle these details efficiently.

Minimizing Memory and Code Size

A single biquad requires storing 5 coefficients and 2 state variables (for transposed direct-form II). That is about 7–10 16-bit words — negligible on any modern MCU. The filter loop can be written in three or four lines of C code. For multiple channels (e.g., stereo audio or multi-sensor), share the same coefficients but maintain per-channel states. This approach scales linearly without blowing memory.

Real-Time Operation

IoT devices often sample sensors at low rates (1 Hz to 1 kHz). A single biquad filter consumes only a few microseconds of CPU time per sample, leaving ample time for other tasks. For continuous data streams, implement the filter in an interrupt service routine (ISR) or via a dedicated DMA circular buffer. Filter coefficients can be changed on-the-fly if the device needs to adapt to different noise conditions, but ensure the switch is done while the filter state is reset to prevent transients.

Power Optimization

Power consumption is a primary concern for battery-powered IoT nodes. The filter itself contributes very little to overall power draw — often less than 0.1% of MCU energy when running at low clock speeds. However, the filter can enable the MCU to use lower sample rates or sleep longer between samples. By removing noise before threshold detection, the device can trigger less frequently. Also, consider using an analog anti-aliasing filter before sampling to relax digital filter requirements, reducing computational load.

Advantages and Trade-offs of Low-Order IIR Filters

Advantages

  • Low computational complexity: Typically 5 multiply-adds per sample for second-order, compared to dozens or hundreds for a FIR filter.
  • Fast processing: Suitable for real-time applications with high sampling rates (e.g., audio up to 48 kHz).
  • Minimal memory requirements: Only a few state variables and coefficients, no tap buffer needed.
  • Ease of implementation: Readily available in MCU DSP libraries; code is short and easy to verify.
  • Good stopband attenuation per order: A second-order IIR can outperform a high-order FIR when linear phase is not required.

Trade-offs and Limitations

  • Nonlinear phase response: IIR filters have frequency-dependent group delay, which can distort signal shapes. This is problematic in applications like ECG or radar where phase correlation matters.
  • Potential instability: Coefficient quantization, especially in fixed-point, can push poles outside the unit circle. Must verify stability at design time.
  • Limited roll-off steepness: For a given order, the transition band is wider than an equivalent FIR with many taps. If you need a very sharp cutoff, you must cascade multiple biquads, increasing complexity.
  • No linear phase: FIR filters can achieve linear phase exactly, making them preferable for certain data communications and image processing.
  • Sensitivity to coefficient rounding: Elliptic filters and high-Q designs suffer from large coefficient changes due to quantization, requiring higher precision (e.g., 32-bit fixed-point or floating-point).

Despite these trade-offs, the majority of IoT sensor filtering tasks (temperature, humidity, pressure, vibration, simple audio) can be adequately served by well-designed low-order IIR filters.

Practical Applications and Examples

Noise Reduction in Temperature Sensors

A temperature sensor output often contains high-frequency noise from ADC quantization and electromagnetic interference. A first-order low-pass IIR filter with a cutoff of 0.1 Hz (if sampling at 1 Hz) smooths the reading without adding significant lag. The coefficients for such a filter are extremely simple — often a single constant alpha where y[n] = alpha * x[n] + (1-alpha) * y[n-1]. This is the classic exponential moving average, which is a first-order IIR. It can be implemented in one line of C code with no multiply if alpha is a power of two (e.g., 1/4 = 0.25). This makes it a favorite for low-end 8-bit microcontrollers.

DC Offset Removal in Accelerometers

Accelerometers used in activity tracking or vibration monitoring often have a DC component due to gravity. A high-pass filter with a very low cutoff (e.g., 0.5 Hz) can remove this offset while passing dynamic signals. A second-order Butterworth high-pass biquad provides sharp roll-off to quickly settle after initialization. The coefficients are derived from the low-pass prototype by replacing s with 1/s in the analog domain.

Audio Pre-Processing for Voice Commands

IoT devices with microphones use low-order IIR filters as part of a voice activity detection (VAD) chain. A band-pass filter (cascade of low-pass and high-pass) centered on the voice frequency range (300–3400 Hz) reduces background noise before feeding into a wake-word detector. The filters must be carefully designed to avoid phase distortion that could affect the consistency of the audio features. Here, Bessel filters are sometimes preferred over Butterworth.

Power Line Noise Rejection

For sensors measuring low-level signals near AC mains, a notch filter (band-stop) at 50/60 Hz is essential. A second-order IIR notch filter can be designed with a very narrow notch. The transfer function places zeros on the unit circle at the notch frequency. The filter requires high precision coefficients because the zeros are exactly on the unit circle; fixed-point implementation must handle this carefully, often requiring 32-bit arithmetic.

Conclusion

Designing low-order IIR filters for IoT devices is a practical balance between signal quality and resource conservation. By selecting the appropriate filter type and carefully quantizing coefficients, developers can achieve effective noise removal and frequency selection with minimal CPU and memory footprint. The simplicity of first- and second-order filters makes them ideal for battery-powered sensors, wearable health monitors, and smart home devices. Always verify stability after coefficient quantization and consider the impact of nonlinear phase on your specific application. With the right design workflow — from specification to fixed-point implementation — low-order IIR filters remain a powerful tool in the IoT signal processing toolbox.