Trust is earned, not given

A different perspective

2021-08-15 · Projects

An audio spectrum display on ESP32/ESP8266: ADC speed meets the FFT

A spectrum analyser — the bouncing bars that show the bass, mids and treble of music — is the most fun way to meet the FFT (Fast Fourier Transform). This repository, ESP32-8266-Audio-Spectrum-Display, contains both an ESP8266 and an ESP32 variant of a live spectrum display on an SSD1306 OLED.

The signal chain, in five steps

  1. Sample — the analog-to-digital converter reads the audio input thousands of times per second into an array.
  2. Transform — the arduinoFFT library converts the samples from "time domain" (what the microphone saw, moment by moment) to "frequency domain" (how much energy lives at each frequency).
  3. Group — the raw output bins are summed into, say, 24 display bands.
  4. Draw — bars go to the OLED via the display driver.
  5. Repeat — faster than the eye notices.

Why the two chips differ so much

The README's headline numbers come from one bottleneck: ADC conversion time. Per Nyquist, to represent 20 kHz audio you must sample at 40 kS/s or better. The ESP8266's ADC cannot keep that pace, so its flat response ends around 5.2 kHz — fine for voice and bass, dull for cymbals. The ESP32 samples faster and takes 512 samples per transform, reaching a flat 20 kHz. Same algorithm, same libraries — the hardware ceiling is the difference.

Build it yourself

Install the arduinoFFT and SSD1306 driver libraries from the Library Manager, wire a microphone module (or line input through a bias circuit) to the ADC pin, and flash. Start with the ESP32 variant; read the README's frequency notes to understand what you are seeing.

Repository: github.com/bobhuang1/ESP32-8266-Audio-Spectrum-Display