This tutorial guides through capturing audio using an ESP32 with an MEMS INMP441 microphone via the I2S protocol and sending these audio samples to a remote server using WiFi. The audio is captured at a sampling frequency of 16KHz, with a 16-bit resolution, in mono channel format.
Ensure you have basic knowledge in electronics, programming with ESP32, and basic experience with Node.js.
- ESP32 Development Board
- INMP441 Microphone with I2S Interface
- Female-to-Female Jumper Wires
- Micro-USB Cable for programming and power supply
First, clone the project repository to your local machine. Open a terminal and run:
git clone https://github.com/alvaro-salazar/esp32-audio-i2s-wav-http.git
cd esp32-audio-i2s-wav-http
This repository contains both the embedded system code (ESP32) and the audio reception server code (Node.js).
- Connecting the Microphone to ESP32: Use the provided connection diagram to connect the INMP441 microphone to the ESP32.
- Verification: Check that all connections are correct to prevent any damage.
Connect the INMP441 to the ESP32 with jumper wires according to the diagram provided:
This outlines the project's architecture (in Spanish). The strategy involves transmitting data to the audio service directly from the reading buffer as soon as it becomes available. To extend the device's lifespan, this code avoids using Flash memory for data storage.
Activity diagram for the application:
cd audioService
npm install
This command will install all necessary dependencies for the Express server.
Ensure you have PlatformIO installed in VSCode. Open the ESP32 project folder with VSCode, and PlatformIO should automatically prepare the environment.
Within the audioService
folder, locate the app.js
file. This contains the setup for the Express server prepared to receive audio files.
To start the server, run:
node app.js
Ensure the server is listening on the configured port before proceeding.
Before loading the code onto your ESP32, ensure to:
- Update WiFi Credentials: Modify the code to include your WiFi network's SSID and password.
- Specify Server Address: Ensure the IP address and port in the ESP32 code match your running Express server.
Load the code onto the ESP32 using PlatformIO or the Arduino IDE.
With the Express server running, restart the ESP32 to begin capturing and sending audio. Check the Express server console to ensure audio data is being received and stored correctly.
If you wish to contribute to this project, consider forking it and submitting your pull requests with improvements or corrections.
This project is distributed under the MIT License. See the LICENSE
file for more details.