Serial at 115200 baudTap a part to see what it does.
Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.
Build it step by step
0 of 4 doneWire the microphone
VCC to 3V3, OUT to GPIO34.
Wire the SD module
CS 5, SCK 18, MOSI 23, MISO 19.
Format the card
FAT32, then insert it.
Upload and leave it
Let it run for an hour, then open noise.csv in a spreadsheet.
How do you build a noise trend logger?
An ESP32 measures loudness from a MAX4466 microphone every 50 ms and writes the average and peak for each minute to a microSD card. You need ESP32 DevKit V1, MAX4466 microphone module, MicroSD Card Module and Breadboard 830 Tie Points. It takes 4 steps and about 55 minutes.
- Level
- Intermediate
- Time
- About 55 min
- Parts
- 4
Parts list
- Development BoardsBuyESP32 DevKit V1 × 1
- SensorsBuy
- InterfacesBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Mic VCC / GND | ESP32 3V3 / GND | Power (3.3 V keeps the output in ADC range) |
| Mic OUT | GPIO34 | Audio |
| SD CS / SCK / MOSI / MISO | GPIO5 / 18 / 23 / 19 | SPI |
| SD VCC / GND | 5V (VIN) / GND | Power for a 5 V module |
Code
Built-in SD library for ESP32. Values are relative (ADC counts), not decibels. Turn the gain trimmer until normal talking reads about 300 to 800.
Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <SD.h>
const int MIC = 34, CS = 5;
long total = 0; int samples = 0, peak = 0;
unsigned long minuteStart = 0;
int window() {
int lo = 4095, hi = 0; unsigned long t = millis();
while (millis() - t < 50) { int v = analogRead(MIC); lo = min(lo, v); hi = max(hi, v); }
return hi - lo;
}
void setup() {
Serial.begin(115200);
if (!SD.begin(CS)) Serial.println("SD card not found");
File f = SD.open("/noise.csv", FILE_APPEND);
if (f) { f.println("minute,average,peak"); f.close(); }
}
void loop() {
int p = window();
total += p; samples++; peak = max(peak, p);
if (millis() - minuteStart >= 60000) {
int avg = total / samples;
File f = SD.open("/noise.csv", FILE_APPEND);
if (f) { f.printf("%lu,%d,%d\n", millis() / 60000, avg, peak); f.close(); }
Serial.printf("avg %d peak %d\n", avg, peak);
total = 0; samples = 0; peak = 0; minuteStart = millis();
}
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Quiet room | Average below about 100 |
| Talk near it | Average and peak rise in the next minute's line |
| Remove the card | "SD card not found" at start-up, no crash |
If it does not work
Constant 4095 peaks
Gain too high, or the mic is on 5 V: use 3V3.
Empty file
Card not FAT32, or wrong CS pin.
Readings never change
OUT not on GPIO34, or the module needs its gain turned up.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the noise trend logger?
ESP32 DevKit V1, MAX4466 microphone module, MicroSD Card Module and Breadboard 830 Tie Points.
How long does the noise trend logger take to build?
About 55 minutes for a intermediate maker, in 4 steps.
How do I know the noise trend logger works?
Quiet room: Average below about 100. Talk near it: Average and peak rise in the next minute's line. Remove the card: "SD card not found" at start-up, no crash.
Constant 4095 peaks: what should I check?
Gain too high, or the mic is on 5 V: use 3V3.
Empty file: what should I check?
Card not FAT32, or wrong CS pin.
Readings never change: what should I check?
OUT not on GPIO34, or the module needs its gain turned up.
