# esp32-inmp441-example

> Check INMP441 microphone with ESP32

- Author: Mikrobot.pl
- Platform: ESP32
- Board: ESP32 Dev Module (`esp32:esp32:esp32`)
- SDK version: 3.3.2
- Tags: #esp32, #example, #captive portal, #inmp441, #microphone
- Created: 2026-06-01
- Updated: 2026-06-01
- Favorites: 0, forks: 0
- Forked from: [Mikrobot.pl/esp32-wifi-example](https://flashesp.com/explore/OxdsToAYujBO6cRV1TAnD.md)
- Project page (view, flash from the browser, fork): https://flashesp.com/explore/MgQhNtyqhiabjpIoApkd6
- Download all sources (zip): https://flashesp.com/api/public-projects/MgQhNtyqhiabjpIoApkd6/download-sources/

## Source files

- [main.ino (11.8 KB)](https://flashesp.com/explore/MgQhNtyqhiabjpIoApkd6/files/3HXb6OPxBoTTkFUshvqmK.md)
- readme.md (7.5 KB)

## README

# ESP32 INMP441 Captive Portal  
### Monitor INMP441 I2S microphone channels via WiFi with a captive portal

This project turns an **ESP32 Dev Board** into a small WiFi-based audio level monitor.  
When powered, the ESP32 creates an **open WiFi Access Point** and a **captive portal**.  
As soon as a device connects to the AP, a web page appears that shows the live signal level from an **INMP441 I2S microphone**.

The web interface displays both I2S stereo channels:

- **LEFT channel**
- **RIGHT channel**

Important: one INMP441 microphone is a **mono microphone**.  
It can transmit on either the LEFT or RIGHT I2S channel, depending on the **L/R pin** connection.  
To get real LEFT and RIGHT audio at the same time, you need **two INMP441 microphones**.

---

## ⭐ Features

- **Open WiFi Access Point** (no password)
  - SSID: `ESP32-INMP441`
- **Captive portal**
  - Any URL request is redirected to the audio monitor page
  - Works with Android / iOS / Windows / Linux
- **Web-based audio level monitor**
  - Shows LEFT channel level
  - Shows RIGHT channel level
  - Shows percentage level
  - Shows dBFS value
  - Shows raw RMS value for debugging
- **I2S microphone support**
  - Designed for INMP441
  - Reads 32-bit I2S samples
  - Supports LEFT / RIGHT channel detection
- No external network or internet required

---

## 📦 Hardware requirements

- **ESP32 Dev Board**  
  Example: ESP32-DevKitC, ESP32-WROOM development board
- **INMP441 I2S microphone module**
- Jumper wires
- Breadboard recommended

---

## 🔌 INMP441 pinout

Typical INMP441 module pins:

| INMP441 pin | Description |
|---|---|
| `VDD` | 3.3V power |
| `GND` | Ground |
| `SCK` / `BCLK` | I2S bit clock |
| `WS` / `LRCL` | I2S word select / left-right clock |
| `SD` / `DOUT` | I2S audio data output |
| `L/R` | Channel select pin |

---

## 🔧 Default wiring: one INMP441 microphone

| INMP441 | ESP32 |
|---|---:|
| `VDD` | `3V3` |
| `GND` | `GND` |
| `SCK` / `BCLK` | `GPIO 26` |
| `WS` / `LRCL` | `GPIO 25` |
| `SD` / `DOUT` | `GPIO 33` |
| `L/R` | `GPIO 27` |

In this version, the `L/R` pin is connected to `GPIO 27`.

The code controls `GPIO 27` automatically:

```cpp
#define MIC_LR_PIN 27
```

You can select the microphone channel in code:

```cpp
#define MIC_CHANNEL_RIGHT true
```

Channel behavior:

| Code setting | L/R state | Active channel |
|---|---|---|
| `MIC_CHANNEL_RIGHT false` | LOW | LEFT |
| `MIC_CHANNEL_RIGHT true` | HIGH | RIGHT |

---

## 🎙️ One microphone vs two microphones

### One INMP441 microphone

One INMP441 is a **mono** microphone.

It can appear as:

- LEFT channel, or
- RIGHT channel

but not both at the same time.

| L/R pin state | Microphone appears as |
|---|---|
| LOW / GND | LEFT channel |
| HIGH / 3.3V | RIGHT channel |

The web page will still display both channels, but only one channel will normally react to sound.

---

### Two INMP441 microphones

To get both LEFT and RIGHT channels working at the same time, use **two INMP441 microphones**.

| Signal | LEFT microphone | RIGHT microphone |
|---|---|---|
| `VDD` | `3V3` | `3V3` |
| `GND` | `GND` | `GND` |
| `SCK` / `BCLK` | `GPIO 26` | `GPIO 26` |
| `WS` / `LRCL` | `GPIO 25` | `GPIO 25` |
| `SD` / `DOUT` | `GPIO 33` | `GPIO 33` |
| `L/R` | `GND` | `3V3` |

Both microphones share the same I2S bus:

```text
SCK
WS
SD
3.3V
GND
```

Only the `L/R` pin must be different.

---

## ⚠️ Important power note

The INMP441 must be powered from **3.3V only**.

Do **not** connect `VDD` to 5V.

If you only have one visible `3V3` pin on your ESP32 board, you can split it using a breadboard or jumper wire.

For example, the same `3V3` pin can power:

- `VDD` of the microphone
- `L/R` pin of the right-channel microphone

The `L/R` pin uses almost no current.  
It only reads a HIGH or LOW logic level.

---

## 📚 Required Arduino IDE setup

Install the ESP32 board package:

1. Open **Arduino IDE**
2. Go to **Tools → Board → Boards Manager**
3. Search for:

```text
esp32
```

4. Install:

```text
esp32 by Espressif Systems
```

No extra libraries are required from the Arduino Library Manager.

The project uses libraries included with the ESP32 Arduino core:

```cpp
#include <WiFi.h>
#include <WebServer.h>
#include <DNSServer.h>
#include "driver/i2s.h"
```

---

## 🌐 WiFi access point

Default WiFi network created by the ESP32:

```text
ESP32-INMP441
```

The network is open and does not require a password.

Default ESP32 access point IP address:

```text
192.168.4.1
```

If the captive portal does not open automatically, open this address manually in a browser:

```text
http://192.168.4.1
```

---

## 🖥️ Web interface

The web page displays:

- LEFT channel level
- RIGHT channel level
- Percentage level for each channel
- dBFS value for each channel
- RMS value for each channel
- ACTIVE indicator when a channel receives signal

The values refresh automatically every 300 ms.

---

## 📏 What is dBFS?

The displayed dB value is **dBFS**, not real-world sound pressure level.

`dBFS` means:

```text
decibels relative to full scale
```

It shows the level of the digital audio signal inside the ESP32.

This is useful for checking:

- whether the microphone works
- which channel is active
- whether the signal changes when sound is present
- whether the wiring is correct

It is not a calibrated dB SPL or dB(A) measurement.

---

## 🧪 Testing

### Test with one microphone

1. Upload the code to the ESP32.
2. Open Serial Monitor at:

```text
115200 baud
```

3. Connect to WiFi:

```text
ESP32-INMP441
```

4. Open:

```text
http://192.168.4.1
```

5. Make sound near the microphone.

If `MIC_CHANNEL_RIGHT` is set to:

```cpp
#define MIC_CHANNEL_RIGHT true
```

then the RIGHT channel should react.

If it is set to:

```cpp
#define MIC_CHANNEL_RIGHT false
```

then the LEFT channel should react.

---

### Test with two microphones

Use two INMP441 modules:

- LEFT microphone: `L/R` connected to `GND`
- RIGHT microphone: `L/R` connected to `3V3`

Both microphones should then react independently on the web page.

---

## 🛠️ Troubleshooting

### The page opens, but both channels show 0%

Check:

- `VDD` is connected to `3V3`, not 5V
- `GND` is connected correctly
- `SCK` is connected to `GPIO 26`
- `WS` is connected to `GPIO 25`
- `SD` is connected to `GPIO 33`
- The microphone is an INMP441 or compatible I2S microphone

---

### Only LEFT or only RIGHT moves

This is normal if you use only one INMP441 microphone.

One INMP441 can transmit on only one channel at a time.

To get both channels moving at the same time, use two microphones.

---

### The wrong channel moves

Change this line:

```cpp
#define MIC_CHANNEL_RIGHT true
```

Use:

```cpp
#define MIC_CHANNEL_RIGHT false
```

for LEFT channel.

Use:

```cpp
#define MIC_CHANNEL_RIGHT true
```

for RIGHT channel.

---

### Captive portal does not open automatically

Manually open:

```text
http://192.168.4.1
```

Some phones or laptops may not automatically show captive portals every time.

---

## 🔢 Default pin configuration

```cpp
#define I2S_WS   25
#define I2S_SCK  26
#define I2S_SD   33

#define MIC_LR_PIN 27
```

Pin meaning:

| Define | ESP32 GPIO | Function |
|---|---:|---|
| `I2S_WS` | `GPIO 25` | Word select / LR clock |
| `I2S_SCK` | `GPIO 26` | Bit clock |
| `I2S_SD` | `GPIO 33` | Audio data input |
| `MIC_LR_PIN` | `GPIO 27` | Microphone LEFT / RIGHT select |

---

## ✅ Summary

This project creates a WiFi captive portal on an ESP32 and displays live audio levels from an INMP441 I2S microphone.

Use one microphone to test either LEFT or RIGHT channel.  
Use two microphones to get real stereo LEFT and RIGHT monitoring.

Default WiFi:

```text
ESP32-INMP441
```

Default web page:

```text
http://192.168.4.1
```
