FFT Spectrum Analyzer with Arduino & Microcontrollers
Real-time frequency domain analysis using the Fast Fourier Transform — no software installation required
What Is the Fast Fourier Transform (FFT)?
The Fast Fourier Transform (FFT) is an efficient algorithm that converts a time-domain signal — a sequence of measurements over time — into its frequency-domain representation. Instead of seeing how a signal changes moment to moment, the FFT reveals which frequencies are present and how strong each one is. It is the mathematical equivalent of separating a musical chord into its individual notes.
The FFT achieves this in O(N log N) operations rather than the O(N²) required by the naive Discrete Fourier Transform (DFT), making real-time spectrum analysis practical on modest hardware and in the browser. The output is two spectra: the magnitude spectrum (signal power at each frequency) and the phase spectrum (the phase offset of each component).
How It Works — From Sensor to Spectrum
The analyzer follows a simple pipeline: a sensor measures a physical quantity, a microcontroller samples the signal through its ADC (Analog-to-Digital Converter), the samples are streamed over USB serial to the browser, and the browser computes the FFT and draws the live spectrum — all with no software to install.
- A sensor converts a physical phenomenon (distance, vibration, sound, voltage) into an electrical signal.
- The microcontroller ADC samples the signal at a fixed rate (e.g. 20 Hz, 1 kHz) and formats readings as comma-separated values.
- Samples are sent over USB serial to the browser via the Web Serial API (Chrome / Edge).
- The browser applies the Cooley-Tukey FFT, zero-padded to the next power of 2, and plots the magnitude and phase spectra in real time.
Connecting Sensors — Examples
Any sensor whose output can be read as a voltage or a digital value can feed this analyzer. Common examples include:
- HC-SR04 ultrasonic sensor — measures distance; reveals vibration and motion frequencies up to ~10 Hz
- ADXL335 / MPU-6050 accelerometer — detects mechanical vibration and shock up to several hundred Hz
- Electret microphone + amplifier — captures audio and speech signals up to several kHz
- ACS712 current sensor — analyzes motor current harmonics and PWM switching frequencies
- Photodiode / LDR — detects light flicker, LED PWM frequencies, or optical modulation
- Any analog voltage (0–5 V / 0–3.3 V) — power supply ripple, bio-signals (ECG/EEG with proper isolation), strain gauges, and more
Connect analog sensors to an ADC pin (e.g. A0 on Arduino) and read them with analogRead(). For signals centered around 0 V, add a Vcc/2 bias so the signal stays within the ADC input range.
Not Just Arduino — Any Microcontroller Works
Because the browser simply reads lines of ASCII numbers over USB serial, any microcontroller or single-board computer that supports USB CDC can act as the data source — including:
- Arduino (Uno, Nano, Mega, Due, MKR) — most accessible starting point
- ESP32 / ESP8266 — Wi-Fi streaming option, 12-bit ADC
- Raspberry Pi Pico — MicroPython support, 12-bit ADC at up to 500 kSPS
- Teensy 4.x — 600 MHz CPU, ideal for high-speed audio FFT
- STM32 Nucleo — professional 12-bit ADC at up to 5 MSPS
- Raspberry Pi — with an external SPI ADC (e.g. MCP3208), stream data from Python
- BeagleBone, Nordic nRF52840, and other platforms with USB serial output
Studying Analog Signals with the ADC
The microcontroller's built-in ADC turns this tool into a versatile signal analyzer for any electrical analog signal. Route a voltage signal into an analog pin and the FFT will reveal its frequency content immediately. This makes it possible to study:
- DC power supply switching ripple and harmonics
- Motor current waveforms and bearing fault signatures
- Audio signals, speech formants, and instrument tones
- Biomedical signals such as ECG / EEG envelopes (with appropriate isolation)
- Seismic or structural strain signals from geophones or strain gauges
- Any periodic or quasi-periodic voltage in the 0–Vcc range
What Engineers and Scientists Can Learn from the Spectrum
Frequency-domain analysis with the FFT is a standard tool across engineering and science disciplines. With this analyzer, professionals and students can:
- Identify resonant frequencies in structures, mechanical systems, or electronic circuits
- Detect harmonic distortion — peaks at 2f, 3f, 4f reveal nonlinear behavior or fault signatures
- Characterize noise — distinguish white noise (flat spectrum) from 1/f noise or narrowband interference
- Diagnose machinery faults — bearing defects, imbalance, and misalignment each produce characteristic spectral patterns
- Perform modal analysis on bridges, beams, or buildings by exciting them and reading their natural frequencies
- Verify signal purity — check oscillators, filters, and amplifiers against their expected frequency response
- Study biological rhythms — heart rate variability, neural oscillations, and respiratory cycles all have spectral signatures
The magnitude spectrum shows dominant frequencies and their relative strength. The phase spectrum reveals timing relationships and system response characteristics — especially valuable at resonance peaks where phase shifts by ±90°.
Bottom line: This FFT Spectrum Analyzer transforms a $5 sensor and any USB microcontroller into a real-time signal processing laboratory — accessible to engineers, scientists, educators, and hobbyists, directly in the browser with zero installation.
