Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tamhow to connect microphone to ESP8266
The simplest and most reliable way to connect a microphone to an ESP8266 is to use an analog microphone module with a built-in preamplifier and connect its analog output to A0. The ESP8266 exposes one user ADC channel, and in the Arduino core the documented external ADC input range is 0 to 1.0 V at the chip ADC input. (arduino.esp8266.com)
Recommended basic wiring for an analog mic module
If your microphone module can output more than 1.0 V at the actual ESP8266 ADC input, you must attenuate it. The safest universal assumption is therefore: keep the ADC input at or below 1.0 V unless you have verified your exact board schematic. (arduino.esp8266.com)
If your goal is only sound/clap detection, not recording, you can also use a microphone module’s digital threshold output and connect that to a GPIO input instead of A0.
The core hardware constraint is that the ESP8266 gives you only one ADC channel, so it is not an audio-oriented MCU in the same class as ESP32. In addition, the ADC is only 10-bit, and Espressif notes that ADC behavior is affected by Wi‑Fi activity and power-saving states; for stable fast acquisition, they recommend special handling and even disabling Wi‑Fi in some cases. (arduino.esp8266.com)
A microphone capsule does not normally connect directly to A0:
That is why, in practice, a MAX4466 / MAX9814 / similar analog mic module is the easiest solution.
1. Best for beginners: analog microphone module
This is suitable for:
2. Raw electret microphone capsule
3. Digital I2S microphone This is where some sample answers were inconsistent. Official Espressif documentation states that the ESP8266EX does have one I2S data input interface and one I2S data output interface, and the official RTOS SDK documents RX mode, TX mode, DMA buffers, and pin configuration APIs. (espressif.com)
For I2S input, the official ESP8266 pin mapping is:
I2SI_DATAI2SI_BCKI2SI_WS (espressif.com)So, if you use an I2S microphone, the correct input-side mapping is:
This corrects the common mistake of putting I2S mic signals on GPIO15 for receive mode; according to the official pin definition, GPIO15 is the I2S output bit clock pin, not the input bit clock pin. (espressif.com)
That said, although I2S exists in the silicon and SDK, for a typical Arduino-style beginner project the analog module on A0 is still the most straightforward path. For serious voice capture, ESP32 is generally the more practical platform.
Analog microphone module ESP8266
------------------------ -------
VCC 3.3V
GND GND
OUT A0
Optional supply filtering near the microphone module:
3.3V ----+---- VCC(mic)
|
100nF
|
GND -----+---- GND(mic)
Also place ~10uF in parallel if Wi‑Fi noise is noticeable.
const int micPin = A0;
void setup() {
Serial.begin(115200);
}
void loop() {
int minVal = 1023;
int maxVal = 0;
unsigned long start = millis();
while (millis() - start < 20) { // 20 ms window
int v = analogRead(micPin);
if (v < minVal) minVal = v;
if (v > maxVal) maxVal = v;
delayMicroseconds(100);
}
int peakToPeak = maxVal - minVal;
Serial.println(peakToPeak);
}
This does not produce hi-fi audio. It gives you a useful sound amplitude estimate over a short time window.
You can also read A0 continuously:
void setup() {
Serial.begin(115200);
}
void loop() {
int s = analogRead(A0);
Serial.println(s);
}
But the practical quality is limited by:
Current official Espressif documentation still shows:
The practical trend in embedded audio is that:
That conclusion is an engineering inference from the documented ESP8266 hardware limits and peripheral set, rather than a direct quote from one source. (arduino.esp8266.com)
Think of the ESP8266 ADC as a narrow measurement window. If the microphone module outputs too large a signal, the waveform clips at the top or bottom. If the module outputs too small a signal, you only measure noise. The goal is to keep the microphone signal inside the ADC window with enough gain to use most of the ADC range.
For analog microphone modules, the output is often centered around a DC bias so that the audio waveform swings around a midpoint rather than around 0 V. That is exactly what the ADC needs, because it cannot measure negative voltage.
For I2S microphones, the analog-to-digital conversion happens in the microphone itself, so the ESP8266 receives digital audio data instead of an analog voltage. This avoids many ADC-noise issues, but the firmware complexity is higher. Espressif’s technical reference and RTOS SDK confirm the availability of I2S input pins and RX mode on ESP8266. (espressif.com)
If the microphone is used for recording or network streaming, obtain consent from people being recorded and verify the rules that apply in your jurisdiction. From an engineering standpoint, also treat microphone data as potentially sensitive and avoid exposing live audio streams without authentication.
From a safety standpoint:
The ADC range and Wi‑Fi sensitivity are documented by Espressif; the privacy point is a general engineering best practice. (arduino.esp8266.com)
Best practice for most users
If using a raw electret capsule
If using an I2S microphone
Common challenges
A key correction to the sample answers is this:
Also note that “connecting a microphone” can mean very different things:
If you want to go further, the next useful topics are:
If you tell me your exact ESP8266 board and microphone module model, I can give you:
For most projects, connect a 3.3 V analog microphone amplifier module to the ESP8266 like this: VCC→3.3 V, GND→GND, OUT→A0. Keep the ADC input within the safe range; the conservative chip-level limit is 0 to 1.0 V. (arduino.esp8266.com)
If you want a digital microphone, the ESP8266 does officially have I2S input capability, and the documented input pins are GPIO12 = DATA, GPIO13 = BCK, GPIO14 = WS. (espressif.com)
Engineering recommendation:
If you want, I can give you a schematic for MAX4466/MAX9814, or a direct wiring diagram for an INMP441 microphone to ESP8266.