Build Project

LED Projects

ESP32 NeoPixel Music Visualizer (Amplitude-Reactive)

Build a real amplitude-reactive NeoPixel visualizer with an I2S digital microphone, external LED power, and honest no-FFT scope.

IntermediateAges 12+75-90 minUnder 35 USDParent Safe
Project Mission

Build an Amplitude-Reactive NeoPixel Visualizer

The Story

The page avoids old FFT and spectrum-analyzer claims. It measures volume changes and maps them to addressable LED output.

Explain Like I'm 12

The microphone sends sound numbers to the ESP32. Louder sound makes bigger numbers, and the ESP32 lights more LEDs.

Learning Support

  • Recommended ageAges 12+
  • Adult supervisionAdult help recommended for checking external 5 V LED power wiring.
  • Classroom useUse it to teach RMS volume measurement, not frequency-spectrum analysis.
  • Parent promptAsk why LED strips need their own power supply and common ground.
  • Screen-free activityCalculate LED current budget on paper before wiring the strip.
  • Next challengeAdd a simple approximate low/mid/high split only after documenting the filter method.
  • Skills practiced
    • I2S sampling
    • RMS amplitude
    • NeoPixel output
    • External power wiring
  • Learning outcomes
    • Wire INMP441 I2S pins.
    • Compute an RMS-like amplitude value.
    • Drive WS2812B LEDs from GPIO5.
    • Explain brightness cap, resistor, capacitor, and common ground.
  • Mini experiments
    • Change sample window size.
    • Map amplitude to color instead of LED count.
    • Add a decay/fade so LEDs settle smoothly.

Safety Standards

  • Unplug USB before changing jumper wires. Recheck 3.3 V, 5 V, and GND before reconnecting power.
  • Do not power motors, pumps, LED strips, or servos from the ESP32 3.3 V pin. Use a suitable external supply and common ground.
  • Breadboards are for low-current prototypes. Move high-current or unattended builds to proper terminals, enclosure, strain relief, and fusing.

What You Will Build

An amplitude-reactive LED strip that responds to volume using I2S microphone samples.

Learning Objectives

  • Wire INMP441 I2S pins.
  • Compute an RMS-like amplitude value.
  • Drive WS2812B LEDs from GPIO5.
  • Explain brightness cap, resistor, capacitor, and common ground.

Components List

  • ESP32 DevKit boardMain 3.3 V logic controller.
  • INMP441 I2S digital microphoneBCLK GPIO14, LRCLK GPIO15, data GPIO32.
  • WS2812B LED strip, 8-30 LEDsExternal 5 V supply required above a few LEDs.
  • External regulated 5 V power supplySized for LED count; do not use ESP32 regulator.
  • 330 ohm data resistorSeries resistor on LED data line.
  • 1000 uF electrolytic capacitorAcross strip 5 V/GND at input.

Bill of Materials

PartQtyEstimated CostNotes
ESP32 DevKit board1VariesMain 3.3 V logic controller.
INMP441 I2S digital microphone1VariesBCLK GPIO14, LRCLK GPIO15, data GPIO32.
WS2812B LED strip, 8-30 LEDs1VariesExternal 5 V supply required above a few LEDs.
External regulated 5 V power supply1VariesSized for LED count; do not use ESP32 regulator.
330 ohm data resistor1VariesSeries resistor on LED data line.
1000 uF electrolytic capacitor1VariesAcross strip 5 V/GND at input.

Wiring

INMP441 uses GPIO14/GPIO15/GPIO32. WS2812B DIN uses GPIO5 through a data resistor. Strip 5 V comes from an external supply with common ground.

Wiring Diagram ESP32 NeoPixel Music Visualizer (Amplitude-Reactive) wiring diagram
  1. 1

    Unplug USB and LED power before wiring.

  2. 2

    Connect INMP441 VDD to 3.3 V, GND to GND, SCK to GPIO14, WS to GPIO15, and SD to GPIO32.

  3. 3

    Connect LED DIN to GPIO5 through a 330 ohm resistor.

  4. 4

    Connect strip 5 V to external 5 V supply positive.

  5. 5

    Connect strip GND, supply GND, and ESP32 GND together.

  6. 6

    Place a 1000 uF capacitor across strip 5 V/GND near the strip input.

GPIO Mapping

SignalESP32 PinDirectionNotes
INMP441 BCLKGPIO14I2S clockDigital microphone bit clock.
INMP441 LRCLKGPIO15I2S word selectBoot strap pin; keep wiring passive.
INMP441 SDGPIO32InputI2S data input.
WS2812B DATAGPIO5OutputUse series resistor.
LED strip powerExternal 5 V / GNDPowerCommon ground with ESP32.

Circuit Explanation

I2S carries digital audio samples from the mic. GPIO5 sends timed LED data while the strip is powered from its own 5 V supply.

Engineering Explanation

The sketch calculates RMS-like amplitude, not frequency bands. BRIGHTNESS_CAP limits current draw and is part of the safety design.

Libraries

  • Adafruit NeoPixelInstall from Arduino Library Manager.
  • driver/i2s.hBundled with Arduino ESP32 core.

Code

Copy into Arduino IDE. Install any libraries noted in the component guides first.

esp32-neopixel-music-visualizer.ino
// ESP32 amplitude-reactive NeoPixel visualizer with INMP441 I2S microphone
// This is volume/RMS reactive, not FFT or spectrum analysis.
#include <Adafruit_NeoPixel.h>
#include "driver/i2s.h"

const int I2S_BCLK = 14;
const int I2S_LRCLK = 15;
const int I2S_DATA = 32;
const int LED_PIN = 5;
const int LED_COUNT = 30;
const int BRIGHTNESS_CAP = 80;

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
int32_t samples[256];

void setupI2S() {
  i2s_config_t config = {};
  config.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX);
  config.sample_rate = 16000;
  config.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT;
  config.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT;
  config.communication_format = I2S_COMM_FORMAT_STAND_I2S;
  config.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1;
  config.dma_buf_count = 4;
  config.dma_buf_len = 256;
  i2s_pin_config_t pins = {I2S_BCLK, I2S_LRCLK, I2S_DATA, I2S_PIN_NO_CHANGE};
  i2s_driver_install(I2S_NUM_0, &config, 0, nullptr);
  i2s_set_pin(I2S_NUM_0, &pins);
}

uint32_t wheel(byte pos) {
  pos = 255 - pos;
  if (pos < 85) return strip.Color(255 - pos * 3, 0, pos * 3);
  if (pos < 170) {
    pos -= 85;
    return strip.Color(0, pos * 3, 255 - pos * 3);
  }
  pos -= 170;
  return strip.Color(pos * 3, 255 - pos * 3, 0);
}

void setup() {
  Serial.begin(115200);
  setupI2S();
  strip.begin();
  strip.setBrightness(BRIGHTNESS_CAP);
  strip.clear();
  strip.show();
  Serial.println("Amplitude visualizer ready. External 5 V LED power required.");
}

void loop() {
  size_t bytesRead = 0;
  i2s_read(I2S_NUM_0, samples, sizeof(samples), &bytesRead, portMAX_DELAY);
  int count = bytesRead / sizeof(samples[0]);
  if (count <= 0) return;

  double sumSquares = 0;
  for (int i = 0; i < count; i++) {
    int32_t s = samples[i] >> 14;
    sumSquares += (double)s * (double)s;
  }
  float rms = sqrt(sumSquares / count);
  int lit = constrain(map((int)rms, 100, 6000, 0, LED_COUNT), 0, LED_COUNT);

  strip.clear();
  for (int i = 0; i < lit; i++) {
    strip.setPixelColor(i, wheel(map(i, 0, LED_COUNT - 1, 100, 0)));
  }
  strip.show();
  Serial.println(rms);
}

Code Explanation

I2S reads 256 samples, computes RMS amplitude, maps it to lit LED count, and writes a capped-brightness NeoPixel bar.

Expected Output

Claps or music increase the number of lit LEDs. Silence settles toward a low or blank state.

Troubleshooting

  • No sound response Check I2S pin mapping and INMP441 L/R wiring.
  • LED flicker Check common ground, data resistor, and external supply.
  • LEDs too bright or supply hot Lower BRIGHTNESS_CAP and reduce LED count.

Common Mistakes

  • Claiming FFT or spectrum analysis.
  • Powering the strip from ESP32 3.3 V.
  • Forgetting common ground.
  • Skipping the data resistor or bulk capacitor.

Testing Checklist

  • Test strip with brightness cap before audio.
  • Clap near the mic and observe response.
  • Check silence does not flicker randomly.

Engineering Tips

  • Start with fewer LEDs.
  • Keep audio and LED power wires tidy.
  • Use RMS values only as relative volume.

Upgrade Ideas

  • Add decay smoothing.
  • Add color themes.
  • Add a documented approximate 3-band filter.

Real-World Applications

  • Volume-reactive desk light
  • RMS amplitude lesson
  • LED power budgeting demo

FAQs

Is this a spectrum analyzer?

No. It reacts to amplitude/volume only.

Why external LED power?

WS2812B strips can draw more current than the ESP32 regulator can supply.

Is the microphone decibel accurate?

No. The values are relative for visual effects.

Review, Testing, and References

Author: Abdul Mubeen and the ESP32 Engine editorial team. Last updated: 2026-06-27. Reviewed: wiring logic, Arduino code structure, beginner safety, and learning sequence.

Educational level: Intermediate. Estimated completion time: 75-90 min. This project is for learning and prototyping; production or unattended hardware needs additional engineering review.

Project Complete!

You completed ESP32 NeoPixel Music Visualizer (Amplitude-Reactive) with matching wiring, code, tests, and limitations.

  • I2S sampling
  • RMS amplitude
  • NeoPixel output