Skip to main content

Vibration Monitoring on ESP32-S3: Predict Bearing Failures Early

GizanTech EngineeringFirmware & Hardware TeamPublished August 24, 20269 min read

The Real Cost of Bearing Failure

Unexpected bearing failure isn't downtime—it's a frozen production line, emergency labor, and damage to adjacent bearings and shafts. For 24/7 industrial motors, fans, and pumps, the cost compounds hourly.

Predictive maintenance solves this. Early warning lets you schedule replacement during planned maintenance, not 3 AM. Traditional vibration monitoring is expensive: dedicated accelerometers, signal conditioning, DAQ boards, constant power draw.

ESP32-S3 changes that equation. A development board and commodity MEMS accelerometer detect bearing spalling 48+ hours before failure. The catch: you need the right hardware layer, signal processing, and realistic deployment expectations. Miss any and you'll miss the window.

Hardware: Accelerometer Selection

The ESP32-S3 itself is overkill for sampling. 240 MHz dual-core Xtensa, 320 kB SRAM, 8 MB PSRAM optional. You'll use maybe 10% of that. The real constraint is the accelerometer and your I/O bandwidth.

Two paths:

I2C (Slow but Simple)

400 kHz I2C delivers 100–150 samples per second. That's 6 bytes per sample (3 axes × 16-bit) = 600–900 bytes/sec. Realistic, but tight. Don't stack other I2C devices on the bus; jitter kills timing.

SPI (Fast, Deterministic)

SPI runs 10–50 Mbps on the ESP32-S3. You can get 5–10 kHz sample rate easily. This is your target for serious early detection. I2C is a fallback for low-power or space-constrained designs.

Accelerometer Selection Trap: Range

Use a 16-bit MEMS accelerometer (MPU6050, ICM-42688, ADXL345—commodities). Here's the trap: range selection kills signal-to-noise ratio. Pick ±16g to avoid clipping on shocks, and your noise floor climbs. Early bearing impulses sit at 0.5–1g peak. At ±16g range, that's 3–6% of full scale, buried in a 10–50 µg/√Hz noise floor.

Instead, pick ±2g or ±4g range. You'll clip on genuine shocks (rare). Early spalling won't trigger clipping. The noise floor drops 4–8× because you're using more of the 16-bit ADC word.

Temperature is Another Trap

MEMS sensitivity drifts at −0.01% per °C. Over a month, a 20 °C swing corrupts your DC baseline. Monthly re-baseline is mandatory; better yet, use a high-pass filter (cutoff 5–10 Hz) to kill the DC component and temperature drift together.

Bearing Fault Frequencies: Where the Defects Hide

Bearings fail by spalling—fatigue cracks in the raceway liberate metal particles. These cracks emit impulsive vibration at bearing-specific harmonic frequencies, not the shaft rotation frequency.

The dominant frequency is the Ball Pass Frequency Outer Race (BPFO):

$$\text{BPFO} = \frac{N}{2} \left(1 + \frac{d}{D} \cos\alpha\right) f_\text{shaft}$$

where N is ball count, d/D is the bore-to-race diameter ratio, α is contact angle, and f_shaft is shaft speed in Hz.

Example: 6-ball bearing running at 1500 RPM (25 Hz shaft speed). Typical geometry gives BPFO ≈ 3.5 × 25 = 87.5 Hz. Early spalling generates impulses at 87.5 Hz, 175 Hz, 262.5 Hz (harmonics), plus sidebands at ±shaft frequency around each. That's 87.5, 112.5, 175, 200, 262.5, 287.5 Hz and higher.

Broadband energy from 50 to 500 Hz. This is not a low-frequency problem.

Ignore this and sample at 500 Hz (Nyquist only 2× top bearing fault frequency). You'll get aliasing and miss the modulation structure that reveals early defects.

Sampling: Nyquist Is a Floor, Not a Target

Here's where designs fail in the field.

Nyquist theorem: sample at 2× the highest frequency component. If BPFO is 87.5 Hz and harmonics extend to 500 Hz, Nyquist says 1000 Hz. Technically compliant. Practically useless.

Why? Because early bearing spalling is a high-frequency impulsive event (kHz range) that's modulated by the bearing fault frequency (10–200 Hz). The impulse energy is spread across fault harmonics with sidebands. Raw FFT at 1000 Hz spreads that energy across bins so broad that early-stage defects drown in noise.

Real requirement: sample at 10–20× the running frequency (not fault frequency). For a 25 Hz shaft, sample at 250–500 Hz minimum; 5 kHz is better. At 5 kHz:

  • Frequency resolution: Δf = 5000 Hz / 4096 samples = 1.2 Hz per bin. You resolve 87.5 Hz fault harmonics clearly.
  • Window duration: 4096 samples / 5000 Hz = 0.8 seconds. Compute FFT in ~20 ms on a single core.
  • Modulation sidebands: fully resolved because your Nyquist margin is 25×, not 2×.

Undersampling is the #1 reason field deployments miss warnings. A 500 Hz sampler won't detect the fault unless it's catastrophic and broadband.

Envelope Demodulation: Gold Standard for Early Detection

Raw FFT is not enough. You need envelope demodulation.

Here's the flow:

  1. High-pass filter (cutoff 1–5 kHz): isolate the high-frequency impulsive component. Bearing defects ring the sensor at kHz frequencies; this filter extracts that.

  2. Rectify (absolute value): convert the narrowband oscillation into an envelope.

  3. Low-pass filter (cutoff 250 Hz for 25 Hz shaft): smooth the envelope to reveal the bearing fault frequency modulation.

  4. FFT the envelope: Now the bearing fault frequencies (87.5 Hz, 175 Hz, etc.) appear as large peaks. Early spalling shows as a 2–3× rise in these peak magnitudes over baseline.

Why this works: Envelope demodulation concentrates impulsive energy from kHz frequencies down into the bearing fault-frequency band (10–200 Hz), where it stands out against the noise floor. Raw FFT spreads the same energy across all bins and you miss it.

Detection window: 48+ hours earlier than raw FFT alone, because early-stage spalling is invisible until you extract the modulation.

Processing StepCutoff / WindowOutput
High-pass filter1–5 kHzImpulsive component
RectifyN/AEnvelope signal
Low-pass filter~250 HzFault-frequency envelope
FFT (4096 point)5 kHz / 4096 = 1.2 Hz/binMagnitude at BPFO, harmonics

Firmware Architecture: Sampling Without Blocking

You can't compute FFT at 5 kHz. Instead, use two independent RTOS tasks:

Sampling Task (Timer ISR, 0.2 ms @ 5 kHz)

  1. Read accelerometer via DMA or fast SPI.
  2. Append 16-bit samples to a 4096-sample ring buffer (SRAM, ~24 KB for 3 axes).
  3. No processing; no blocking.

Analysis Task (Every 4 Hours)

  1. Copy ring buffer to PSRAM (if WiFi active; else use SRAM).
  2. Apply high-pass filter to each axis.
  3. Rectify and apply low-pass filter.
  4. Compute FFT on envelope (20 ms compute time).
  5. Extract peak magnitudes at BPFO and harmonics.
  6. Compare to 48-hour rolling baseline.
  7. If peak magnitude rises >2–3× over 24 hours, set alert flag.
  8. Log spectrum to SD card (forensics).

Alert Task (Async)

If flag set, transmit alert via WiFi (100 ms, 8 mJ). Reset flag.

Memory Budget

  • Ring buffer: 24 KB (4096 samples × 3 axes × 2 bytes).
  • FFT workspace: 4 KB (esp-dsp library).
  • Output buffer: 16 KB.
  • WiFi stack: ~100 KB heap if active.
  • Total: fits 320 KB SRAM without BLE; use PSRAM if WiFi needed.

Power Envelope

  • I2C/SPI idle: 0.5 mA (leakage).
  • I2C reads (4 hours @ 5 kHz, 50 µA average): ~200 µA continuous.
  • FFT compute (1× daily, 50 ms @ 240 MHz): negligible.
  • WiFi alert (1× daily, 100 ms @ 80 mA): ~2 mAh.
  • Total: 22 mAh/day. A 180 mAh cell lasts ~8 days.

Switch to hourly sampling and it extends to weeks. You trade temporal resolution for endurance.

Deployment: Site Commissioning and Tuning

No universal threshold exists. A 0.5g vibration is alarming in a small pump; normal in a large industrial fan. Bearing type, mounting stiffness, load pattern, and thermal environment all shift the baseline.

Commissioning (1–2 weeks):

  1. Mount sensor perpendicular to bearing axis (radial catches outer-race defects; axial catches thrust).
  2. Collect FFT windows during normal operation, varying load.
  3. Establish noise floor as the 5th–10th percentile magnitude in the BPFO band.
  4. Set alarm threshold at 2–3× noise floor.
  5. Trend for 24–48 hours: If RMS or peak climbs consistently, flag. Single spike = false alarm.

Real-World Tuning

  • Small motor (500W, 3000 RPM): tight thresholds. BPFO ~250–500 Hz, vibration baseline low, margin for error slim.
  • Large fan (10 kW, 1800 RPM): loose thresholds. BPFO 60–150 Hz, higher baseline, more margin.

Adaptive thresholding (Kalman filter or exponential moving average on RMS) reduces manual re-tuning as baseline shifts with age and load.

Failure Modes: What Goes Wrong

Clipping (Sensor Saturated)

Impact or shock exceeds ±16g. High-pass filter won't save you; the ADC clips. Use lower gain if the accelerometer supports it. Check the datasheet for maximum non-destructive impact rating.

Aliasing (Undersampling)

Most common mistake. 500 Hz sampling for 500 Hz bearing faults aliases energy into false frequencies. You'll see "peaks" that don't exist. Verify Nyquist margin before first deployment; 5 kHz is your safety net.

Sensor Drift (Temperature + Age)

Offset creeps 0.01% / °C. Over weeks, DC baseline corrupts. High-pass filter (cutoff 5–10 Hz) kills it; monthly re-baseline is safer and more robust.

Expert Takeaways

Key takeaways

  • Envelope demodulation is mandatory for early detection. Raw FFT spreads impulsive energy too thin; demodulation concentrates it into bearing-fault-frequency peaks visible 48+ hours before failure.
  • Nyquist is a floor. Sample at 10–20× running frequency (not fault frequency) to resolve modulation sidebands and impulse structure.
  • Trending defeats false alarms. Set thresholds on 24–48 hour rolling windows, not single snapshots. Hourly sampling with daily FFT balances power draw and detection latency.
  • Baseline and thresholds are site-specific. Budget 1–2 weeks per installation for commissioning and adaptive tuning. There is no universal alarm level.

Building Industrial Vibration Monitoring

Building vibration monitoring into ESP32 designs is straightforward once you understand the signal processing. The hardware is cheap; the real cost is getting the Nyquist margin, envelope demodulation, and deployment tuning right. Miss any of those and you'll have a monitoring system that reports failures after they're catastrophic.

GizanTech builds industrial IoT stacks where predictive maintenance and early warning are requirements, not nice-to-haves. The patterns here scale from single-bearing prototypes to multi-machine fleet monitoring with centralized baseline and threshold management.

Start with 5 kHz sampling, envelope demodulation, and adaptive thresholding. Tune on-site. Monitor the trend. The 48-hour early window is real—and it pays for the sensor a thousand times over.

:::

Frequently asked questions

What's the minimum sampling rate for bearing fault detection?

Minimum is 5 kHz, but Nyquist theorem alone isn't enough. Bearing fault frequencies like BPFO are modulated by running frequency across sidebands. Sampling at 2× fault frequency (Nyquist minimum) spreads that modulation across FFT bins so broad that early spalling drowns in noise. Sample at 10–20× running frequency instead to resolve modulation sidebands. For a 25 Hz shaft, that's 250 Hz minimum, 5 kHz preferred.

Why is envelope demodulation better than raw FFT?

Early bearing spalling is a narrow-band impulsive event in the kHz range, modulated by fault frequency (10–200 Hz). Raw FFT spreads impulse energy across frequency bins so diffusely that it's invisible against broadband noise. Envelope demodulation (rectify + low-pass filter) concentrates that kHz energy into fault-frequency peaks. Result: defects visible 48+ hours earlier. Early spalling is modulation, not broadband—you must extract it to see it.

How do I avoid false alarms in production?

Never threshold on single-sample FFT snapshots. Load transients, external vibration, and normal operation variability all spike peaks momentarily. Instead, trend RMS magnitude or kurtosis over 24–48 hour rolling windows. Alarm when the trend line climbs consistently, not when any single snapshot exceeds a limit. Combine hourly or 4-hourly FFT sampling with adaptive thresholds (Kalman filter, exponential moving average) tuned to your specific machine baseline.

What's the typical battery life with 5 kHz sampling?

Sampling 4 hours daily at 5 kHz draws ~20 mAh/day for I2C reads and CPU. Add ~2 mAh for WiFi alerts and computation. A 180 mAh battery cell lasts roughly 8 days. If power is critical, switch to hourly sampling (1 minute/hour, FFT once daily)—extends runtime to weeks. The trade-off is coarser temporal resolution: you still detect bearing degradation, but observe it over a longer window. 22 mAh/day is your baseline.

Related solutions

See how we apply this in production, by industry: