11-17-2025, 02:45 PM
Thread 10 — Build Your Own Digital Spectrum Analyzer
A Complete Beginner-Friendly Project That Teaches FFT, Audio Sampling, and DSP
A spectrum analyzer takes in sound (or any signal), runs a Fast Fourier Transform (FFT),
and displays the frequency intensities in real time.
Phones, music software, audio mixers, smart speakers — they ALL use this.
In this thread, you will learn:
• how FFT reveals hidden frequencies
• how to capture audio with a microcontroller
• how to process signals digitally
• how to display a live spectrum
• how to build your own DIY analyzer from scratch
This is a full hands-on engineering project.
1. What This Project Does
Your finished device will:
• read audio through a microphone module
• sample the waveform in real time
• run an FFT on blocks of samples
• convert the result into frequency bins
• display the spectrum on LEDs or an OLED screen
You can visualize:
• voice frequencies
• bass, mids, treble
• environmental noise
• musical tones
• claps, whistles, vibrations
2. Parts You Need (Beginner-Friendly Kit)
All parts are inexpensive and safe:
• ESP32 or Arduino Nano RP2040 (recommended for speed)
• MAX4466 or KY-037 microphone module
• 128×64 OLED display (I2C) OR WS2812 LED strip
• Jumper wires
• USB cable
• Breadboard
Optional:
• 3D-printed enclosure
• Li-ion battery
• Charging module
Total cost: £15–£25 depending on parts.
3. The Core Idea — Sampling + FFT
To analyse sound digitally we must:
(1) SAMPLE → convert analog audio → numbers
(2) BUFFER → store N samples
(3) FFT → convert time data → frequency data
(4) DISPLAY → show bars for each frequency band
Most projects use:
N = 256 or 512 samples
Perfect for real-time performance on microcontrollers.
4. Wiring Diagram (Simple)
Microphone → ADC Input
• Mic OUT → A0 (or ADC pin)
• VCC → 3.3V
• GND → GND
OLED → I2C
• SDA → SDA
• SCL → SCL
• VCC → 3.3V
• GND → GND
That’s it — simple wiring.
5. Sample Rate Setup
To capture frequencies up to ~4 kHz,
you need a sampling rate of:
Fs = 8000 Hz
This works great for voices and environmental sound.
6. Core Code (ESP32 Example)
Below is a clean, ready-to-run FFT spectrum analyzer sketch.
This uses:
• ArduinoFFT library
• I2C OLED
• 256-sample FFT window
This produces a live moving bar-graph spectrum.
7. Understanding the Frequency Bins
For N=256 samples and Fs=8000 Hz:
Frequency resolution = Fs / N
= 8000 / 256
≈ 31.25 Hz per bin
Examples:
• bin 5 ≈ 156 Hz
• bin 10 ≈ 312 Hz
• bin 20 ≈ 625 Hz
• bin 40 ≈ 1250 Hz
Users can identify:
• bass frequencies
• human voice range
• whistles & alarms
• fan noise (400–1200 Hz)
• wide environmental noise
8. Add a Logarithmic Display (Better for Human Hearing)
Human ears are logarithmic — so you group FFT bins
into octave or semi-octave bands.
Example grouping:
• 0–200 Hz
• 200–400 Hz
• 400–800 Hz
• 800–1600 Hz
• 1600–3200 Hz
Let beginners understand professional audio tools.
9. Real Upgrades You Can Add Later
• RGB LED matrix visualizer
• Real-time noise reduction
• Bluetooth streaming to your phone
• Microphone beamforming
• Displaying a full spectrogram
• Adding a waterfall effect
• Recording peaks & analysing environments
• Using DSP to classify sounds (machine learning)
This project scales all the way up to professional engineering.
10. What You Learned
By completing this thread you learned:
• how sampling works
• how FFT converts signals into frequencies
• how filters and windows improve signal quality
• how microcontrollers do real DSP
• how engineering projects are built from theory → hardware → code
• how to build a real working spectrum analyzer
This is core knowledge for:
• audio engineering
• robotics
• astronomy
• seismology
• communication systems
• machine learning
• embedded systems design
End of Thread — Build Your Own Digital Spectrum Analyzer
Written by LeeJohnston & Liora — The Lumin Archive Research Division
A Complete Beginner-Friendly Project That Teaches FFT, Audio Sampling, and DSP
A spectrum analyzer takes in sound (or any signal), runs a Fast Fourier Transform (FFT),
and displays the frequency intensities in real time.
Phones, music software, audio mixers, smart speakers — they ALL use this.
In this thread, you will learn:
• how FFT reveals hidden frequencies
• how to capture audio with a microcontroller
• how to process signals digitally
• how to display a live spectrum
• how to build your own DIY analyzer from scratch
This is a full hands-on engineering project.
1. What This Project Does
Your finished device will:
• read audio through a microphone module
• sample the waveform in real time
• run an FFT on blocks of samples
• convert the result into frequency bins
• display the spectrum on LEDs or an OLED screen
You can visualize:
• voice frequencies
• bass, mids, treble
• environmental noise
• musical tones
• claps, whistles, vibrations
2. Parts You Need (Beginner-Friendly Kit)
All parts are inexpensive and safe:
• ESP32 or Arduino Nano RP2040 (recommended for speed)
• MAX4466 or KY-037 microphone module
• 128×64 OLED display (I2C) OR WS2812 LED strip
• Jumper wires
• USB cable
• Breadboard
Optional:
• 3D-printed enclosure
• Li-ion battery
• Charging module
Total cost: £15–£25 depending on parts.
3. The Core Idea — Sampling + FFT
To analyse sound digitally we must:
(1) SAMPLE → convert analog audio → numbers
(2) BUFFER → store N samples
(3) FFT → convert time data → frequency data
(4) DISPLAY → show bars for each frequency band
Most projects use:
N = 256 or 512 samples
Perfect for real-time performance on microcontrollers.
4. Wiring Diagram (Simple)
Microphone → ADC Input
• Mic OUT → A0 (or ADC pin)
• VCC → 3.3V
• GND → GND
OLED → I2C
• SDA → SDA
• SCL → SCL
• VCC → 3.3V
• GND → GND
That’s it — simple wiring.
5. Sample Rate Setup
To capture frequencies up to ~4 kHz,
you need a sampling rate of:
Fs = 8000 Hz
This works great for voices and environmental sound.
6. Core Code (ESP32 Example)
Below is a clean, ready-to-run FFT spectrum analyzer sketch.
This uses:
• ArduinoFFT library
• I2C OLED
• 256-sample FFT window
Code:
// ==== LIBRARIES ====
#include <ArduinoFFT.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#define SAMPLES 256
#define SAMPLING_FREQUENCY 8000
double vReal[SAMPLES];
double vImag[SAMPLES];
ArduinoFFT FFT = ArduinoFFT(vReal, vImag, SAMPLES, SAMPLING_FREQUENCY);
Adafruit_SSD1306 display(128, 64, &Wire);
// ==== SETUP ====
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.display();
analogReadResolution(12); // ESP32 high-quality ADC
analogSetPinAttenuation(34, ADC_11db);
}
// ==== MAIN LOOP ====
void loop() {
// 1. Collect samples
for (int i = 0; i < SAMPLES; i++) {
vReal[i] = analogRead(34);
vImag[i] = 0;
delayMicroseconds(1000000 / SAMPLING_FREQUENCY);
}
// 2. Apply a Hanning window
FFT.Windowing(FFT_WIN_TYP_HANN, FFT_FORWARD);
// 3. Compute the FFT
FFT.Compute(FFT_FORWARD);
// 4. Convert to magnitudes
FFT.ComplexToMagnitude();
// 5. Display the spectrum
display.clearDisplay();
for (int i = 2; i < 64; i++) {
int barHeight = map(vReal[i], 0, 2000, 0, 60);
display.drawLine(i*2, 63, i*2, 63 - barHeight, WHITE);
}
display.display();
}This produces a live moving bar-graph spectrum.
7. Understanding the Frequency Bins
For N=256 samples and Fs=8000 Hz:
Frequency resolution = Fs / N
= 8000 / 256
≈ 31.25 Hz per bin
Examples:
• bin 5 ≈ 156 Hz
• bin 10 ≈ 312 Hz
• bin 20 ≈ 625 Hz
• bin 40 ≈ 1250 Hz
Users can identify:
• bass frequencies
• human voice range
• whistles & alarms
• fan noise (400–1200 Hz)
• wide environmental noise
8. Add a Logarithmic Display (Better for Human Hearing)
Human ears are logarithmic — so you group FFT bins
into octave or semi-octave bands.
Example grouping:
• 0–200 Hz
• 200–400 Hz
• 400–800 Hz
• 800–1600 Hz
• 1600–3200 Hz
Let beginners understand professional audio tools.
9. Real Upgrades You Can Add Later
• RGB LED matrix visualizer
• Real-time noise reduction
• Bluetooth streaming to your phone
• Microphone beamforming
• Displaying a full spectrogram
• Adding a waterfall effect
• Recording peaks & analysing environments
• Using DSP to classify sounds (machine learning)
This project scales all the way up to professional engineering.
10. What You Learned
By completing this thread you learned:
• how sampling works
• how FFT converts signals into frequencies
• how filters and windows improve signal quality
• how microcontrollers do real DSP
• how engineering projects are built from theory → hardware → code
• how to build a real working spectrum analyzer
This is core knowledge for:
• audio engineering
• robotics
• astronomy
• seismology
• communication systems
• machine learning
• embedded systems design
End of Thread — Build Your Own Digital Spectrum Analyzer
Written by LeeJohnston & Liora — The Lumin Archive Research Division
