Skip to content
Home » Embedded Systems » Sensors » Noise in Sensor Measurements: Sources and Solutions

Noise in Sensor Measurements: Sources and Solutions

Sensors for Embedded Systems
Part 8 of 18View Full Path →

KEY TAKEAWAYS

  • Sensor noise comes from thermal effects, EMI, quantization, power supply ripple, ground loops, and self-heating
  • Hardware solutions include decoupling capacitors, RC filters, shielded cables, twisted pair wiring, and differential signaling
  • Software solutions include simple averaging, median filtering, exponential moving average (EMA), and oversampling
  • Always combine hardware and software filtering — hardware removes high-frequency noise before the ADC, software smooths what remains

Part of the Complete Guide to Sensors for Embedded Systems series.

Noise is the enemy of accurate sensor measurements. A perfectly calibrated sensor is useless if electrical noise corrupts its output. Every embedded system that reads analog sensors deals with this problem. This article covers the most common noise sources, practical hardware techniques to reduce them, and software filtering algorithms you can implement immediately.

Common Noise Sources

Thermal Noise (Johnson-Nyquist Noise)

Every resistor generates random voltage noise due to thermal agitation of electrons. This noise exists in every circuit, regardless of how well you design it. The noise voltage is proportional to temperature, resistance value, and measurement bandwidth. Practically, this means: higher-value resistors in your voltage divider or sensor circuit produce more noise. If your sensor signal is weak (millivolt range), thermal noise can become significant.

Reducing thermal noise: use lower-value resistors where possible, narrow the measurement bandwidth with a low-pass filter, and keep the circuit cool (relevant in industrial environments).

EMI (Electromagnetic Interference)

The most common noise source in real-world embedded systems. Motors, switching power supplies, relays, solenoids, and wireless transmitters all radiate electromagnetic energy that couples into sensor wires. The effect is worst when sensor wires run parallel to power cables or near switching components.

A typical symptom: your temperature sensor reads correctly on the bench but shows random spikes when installed near a motor. The motor’s PWM drive signal induces voltage spikes on the sensor wire every time it switches.

EMI can be conducted (through shared power supply or ground wires) or radiated (through the air). Both require different countermeasures.

Quantization Noise

An ADC converts a continuous analog voltage to discrete digital steps. A 10-bit ADC with a 3.3V reference divides the input range into 1024 steps, each representing 3.22mV. Any voltage variation smaller than one step is lost — the ADC cannot see it. This “rounding error” appears as stepping or jitter in the output, especially when the real signal sits between two ADC levels.

For example, if a temperature sensor outputs 1.614V (representing 25.0°C) but the nearest ADC levels are 1.612V and 1.615V, the reading will alternate between these two values even though the actual temperature is perfectly stable.

Ground Loops

When the sensor and the microcontroller have different ground potentials — common in systems with multiple power supplies or long cable runs — current flows through the ground connection, creating a voltage offset. This shows up as a DC shift in your readings, or as 50/60Hz noise picked up from mains power.

Ground loops are particularly problematic in industrial systems where sensors may be meters away from the controller, and different parts of the system have separate power supplies sharing a common ground bus.

Power Supply Noise

Switching voltage regulators (buck converters, boost converters) produce ripple at their switching frequency, typically 100kHz to 2MHz. This ripple appears directly in analog sensor readings. A 50mV ripple on a 3.3V supply means your ADC readings can vary by up to 15 LSBs on a 10-bit ADC — without any actual change in the sensor signal.

Linear regulators (LDO) produce much cleaner power with microvolt-level ripple, but are less efficient (waste energy as heat). For sensitive analog circuits, many designs use a switching regulator for digital logic and a separate LDO for the analog sensor supply.

Self-Heating

Sensors that draw current dissipate power as heat, which can warm the sensor itself and affect the reading. This is most noticeable with temperature sensors and resistive humidity sensors. A thermistor in a constant-current measurement circuit heats itself slightly, reading a temperature higher than the actual ambient. The solution is to minimize excitation current or use pulsed measurements — energize the sensor only during the reading.

Hardware Noise Reduction

Always address noise in hardware first. No amount of software filtering can recover a signal that is already corrupted beyond recognition.

Decoupling Capacitors

Place a 100nF ceramic capacitor as close as possible to each sensor’s power pin. Add a 10µF electrolytic (or tantalum) at the power entry point. The ceramic absorbs high-frequency noise; the electrolytic handles lower-frequency power supply sag during current spikes. This is the single most effective hardware noise reduction technique and should be applied to every sensor in every design.

RC Low-Pass Filter

A resistor and capacitor between the sensor output and the ADC input form a passive low-pass filter. The cutoff frequency is:

f = 1 / (2π × R × C)

For a 10kΩ resistor and 100nF capacitor, the cutoff is about 159Hz. Noise above this frequency is attenuated. Since most physical quantities (temperature, humidity, pressure) change slowly (under 10Hz), this filter removes high-frequency noise without affecting the actual signal. Choose R and C values to set the cutoff just above your signal’s maximum frequency of change.

Shielded and Twisted Pair Cables

For sensors connected via cable (not on the same PCB), use shielded cable for long runs. Connect the shield to ground at one end only to avoid creating a ground loop. Twisted pair wiring is simpler and often sufficient — twisting signal and ground wires together causes induced EMI to affect both wires equally, and the difference (which is what you measure) cancels out.

Differential Signaling

Instrumentation amplifiers measure the voltage difference between two inputs, rejecting any noise that is common to both inputs (common-mode rejection). This is essential for low-level signals like thermocouples (millivolt output) and strain gauges (microvolt output). If your sensor outputs a single-ended signal in a noisy environment, consider adding an instrumentation amplifier stage before the ADC.

PCB Layout Practices

On PCBs, separate analog and digital ground planes and join them at a single point near the ADC. Route analog traces away from digital signals, clock lines, and power switching traces. Keep ADC input traces as short as possible. Place a ground guard ring around sensitive analog traces to absorb radiated noise.

Software Noise Filtering

Software filtering complements hardware filtering. It handles the residual noise that hardware cannot eliminate. Here are the most common algorithms used in embedded systems, in order of complexity:

Simple Averaging

Read the ADC N times and divide by N. Random noise averages out, improving the signal-to-noise ratio by a factor of √N. Taking 16 samples reduces noise by 4x. Taking 64 samples reduces it by 8x.

uint16_t adc_read_averaged(uint8_t channel, uint8_t num_samples) {
    uint32_t sum = 0;
    for (uint8_t i = 0; i < num_samples; i++) {
        sum += adc_read(channel);
    }
    return (uint16_t)(sum / num_samples);
}

Downside: increases response time proportionally. 64 samples at 10µs each means 640µs per reading. Fine for temperature, too slow for a fast-changing signal.

Median Filter

Read N samples, sort them, take the middle value. Unlike averaging, a median filter completely rejects outlier spikes. If 5 readings are [512, 510, 980, 511, 513], averaging gives 605 (corrupted by the 980 spike). The median gives 511 (correct).

uint16_t median_filter(uint16_t *samples, uint8_t n) {
    // Simple bubble sort for small N (3 or 5)
    for (uint8_t i = 0; i < n - 1; i++) {
        for (uint8_t j = 0; j < n - i - 1; j++) {
            if (samples[j] > samples[j+1]) {
                uint16_t temp = samples[j];
                samples[j] = samples[j+1];
                samples[j+1] = temp;
            }
        }
    }
    return samples[n / 2];
}

A 5-sample median filter is the go-to solution for spike noise from EMI. It adds minimal latency and is very effective against intermittent interference.

Exponential Moving Average (EMA)

The EMA is the most memory-efficient filter — it only stores one previous value:

// alpha: 0.0 to 1.0
// Lower alpha = more smoothing, slower response
// Higher alpha = less smoothing, faster response
float ema_filter(float new_sample, float prev_filtered, float alpha) {
    return alpha * new_sample + (1.0f - alpha) * prev_filtered;
}

// Usage:
static float filtered = 0;
filtered = ema_filter(adc_read(0), filtered, 0.1f);  // Heavy smoothing

An alpha of 0.1 means only 10% of each new reading affects the output. This gives excellent smoothing but slow response to real changes. An alpha of 0.5 gives a balanced trade-off. Choose alpha based on how fast your measured quantity actually changes.

EMA is particularly popular on resource-constrained MCUs (8-bit AVR, small Cortex-M0) because it needs only one variable and one multiply-add per sample. No arrays, no sorting.

Oversampling for Extra Resolution

By sampling at a rate much higher than needed and averaging, you effectively increase ADC resolution. Each 4x oversampling adds approximately 1 bit of resolution. A 10-bit ADC sampling 256 times and averaging achieves near 14-bit effective resolution.

This works because random noise “dithers” the ADC input, causing it to toggle between adjacent codes. Averaging these toggled values recovers sub-LSB information that a single sample cannot capture.

Choosing the Right Approach

In practice, the best noise reduction combines multiple techniques:

  1. Hardware first: Decoupling capacitors on every sensor. RC low-pass filter before the ADC input. Clean power supply for analog circuits.
  2. Median filter in software: Removes any remaining spike noise that hardware filtering missed.
  3. EMA after median: Smooths the spike-free signal for a stable final reading.

This three-stage approach (hardware RC → median → EMA) handles virtually every noise problem in embedded sensor systems. Start with this combination and simplify only if you have proven it is unnecessary for your specific application.

📖 Related: LM35 Temperature Sensor: Working, Circuit, and Arduino Code

Going further: For the firmware-side fixes — moving average, median, EMA, oversampling, and hysteresis — see our companion guide on Filtering Noisy ADC Readings.

Leave a Reply

Your email address will not be published. Required fields are marked *