WiFi Spy Microphone With ESP32 Arduino Source code+schematic

Other projects from this group

WiFi Spy Microphone With ESP32 Arduino Source code+schematic

With this source code, an ESP32 Devkit module and a standard microphone module, build a 240kbps WiFi Spy microphone with audio recorder and live stream player..

ESP32 WiFi Voice Recorder Arduino Source Code and Schematic - rev 2.1



Other projects from this group


The “DOIT ESP32 DEVKIT V1” module has multiple ACD pins which work in range of 0V to 3.3V with 12 bits resolution (0-4095). The pin that we have used for this project is GPIO33 (D33). In the “ESP32 WiFi Microphone” project, we have used this channel as the audio signal input.

This project is based on the “ESP32 WebApp Builder” project which is a base source code with the chain network feature and is able to play the audio stream in up to 240Kbps.

The module reads audio signal from ADC pin, then decode it to audio data and transmits it to the web UI. Web browser receives the data and stars recording it to a WAV file as soon as the user opens the main web page ( Also the user can play the recorded audio live-ly at the same time.

This project contains a folder (ESP32WiFiMicrophone) which is the WiFi Microphone source code.

There are the following files in this project:

  1. ESP32WiFiMicrophone.ino (Main handler file)
  2. user_global.h – Project global variables and definitions file.
  3. user_init.ino – Project initial script file.
  4. user_loop.ino – This file has a “userLoop()” function which calls repeatedly (like arduino “loop()” function).
  5. user_settings.ino – Project settings file.
  6. user_main.ino – Audio player handler script.
  7. user_sub.ino – Network monitor handler script.
  8. Webapp.h – This file contains the WiFi ECG WebApp’s script.

The Web Application:

wifi microphone mobile app

The circuit with "DO IT ESP32 DEVKIT V1" and "Waveshare Sound Sensor":

esp32 wifi microphone

ESP32 WiFi Spy Microphone Schematics

The GPIO33 pin (ADC5) of esp32 is the audio signal input. Before using the WiFi microphone, build one of the following circuits. Here’s a circuit with a simple capacitive microphone, LM386 and ESP32:

esp32 wifi microphone shcematic

Auto Voice Recorder (Rev 2.0 Only)

You can either use a prepared SD/MMC memory card module (with resistors and the 3.3V regulator) or use a slot and add the resistors to your circuit.

In case you are using ESP32 Boards, it’s suggested to use a memory module with a 3.3V regulator and supply it with 5V (“Vin”), because it reduces the ESP module’s power supply noises and the ESP module’s internal regulator heat.

voice recorder esp8266 nodemcu sd mmc

For recording the voices automatically, insert a memory card, turn on the module and select the sensitivity (10db, 20db and 30db for the louder noises).

Then the device start to hearing the noises and as soon as hearing the load enough noised, it starts to recording it in a .wav file with the selected quality and record time.

When the recording is finished, the file will be available in the file manager.

voice recorder esp8266 esp32 nodemcu sd mmc file manager

  • You can record the audio and listen to the stream online at the same time, but in this situation, the quality may reduce.
  • Opening the file manager stops the recording.
  • The LED will blink during recording

The Chain Network

The “Chain Network” is a local network which the devices one by one are connected to the each other (Series). In the chain network, the first device is the master of network. The starter (either the master or the last joined module) is directly connected to the WebApp. It sends the command to the next device, and the next device sends it to the next one till the last device. The last device response will be sent to the first device and finally the WebApp via the middle devices.

The ESP32 WiFi Microphone Web Application

Plug the power and turn on the circuit and the module in “normal mode”.

Then the blue LED on the board would be turned on. Then you’ll be able to see the module’s hot spot ssid via the WiFi networks in your PC or smart phone.

The default SSID is WiCardMic and the default password is 12345678. Connect and go to with a PC or smart phone web browser (Chrome or Firefox).

Here’s the web UI:

wifi microphone web application esp8266 nodemcu

Right after loading the page, the module starts recording and buffering automatically. By clicking on the play button, the recorded sound will play.

This page records audio data to in the browser’s cache automatically. Also you can play the audio and listen to the audio lively at the same time.

  • It’s suggested before click on the play button, wait for a few seconds for buffering.

The preset time can be 5, 10, 30 and 60 minutes. After this time spent, you can refresh the page and record again.

To downloading the audio file directly, go to (or the router’s given IP).

Above of the audio player, you can see the target device.

  • If you close the web page, recording will be aborted.
  • Do not open two pages at the same time. The module can handle only one page at a time.
  • The WiFi signal strength takes effect on the module capability and the audio streams.
  • This web application is also compatible with cell phone and mobile device browsers:

The menus

The Web Application is divided to 3 menus. The menus can be selected by click on the menu button

“Player” refers to the “Audio Player” page, “Network” refers to the Network WiFi Microphone Monitor and “Settings” refers to the settings page.

The Network WiFi Microphone Monitor (Scope)

In the “Network” page, there are 8 scope channels. That means you can add up to 8 devices to the chain network and see the audio signals at the same time.

wifi network microphone esp8266 nodemcu

In the above picture, only two devices (CH0 and CH1) are connected to the network.

By click on each channel, the target device in the audio player page will change to the selected device.

Programming Manual

For the programming, use the pre-defined functions in the files which start with “user”.

Add your start-up script to the “userInit()” function in user_init.ino file. No need to do wifi or server configuration. This configuration already have done in the firmware system files (e.g. systemInit() and setup()).

The “userLoop()” function (user_loop.ino) calls repeatedly (like arduino “loop()” function), If your program needs to execute a statement repeatedly (e.g. reading a sensor’s data), insert your script in this function.

The “webapp.h” file is the root page’s script. You can customize sWebApp variable in that file if you’re going to make changes in the Web UI.

Also you can customize the “userGetSettings()” function (user_settings.ino), for adding more settings to the firmware. The WebApp execute this function when you click on the Settings menu.

After you click on the SAVE button of the user-defined settings, the “userSetSettings()” functions will be called.

  • The settings will not be shared in the network and each device has its own settings.

The “userMain()” in the “user_main.ino” file, calls once when you click on the “Player” menu (or initially after loading the root page).

The “userSubInit()” in the “user_sub.ino” file, calls once when you click on the “Network” menu and sends the available devices in the network back..

The “userSub()” in the “user_sub.ino” file, calls intervally and the starter collects the scope data in the chain network.

  • The “networkStarterCheck()” bool functions says whether the module is the network starter or not.

The “userGlobal()” function in the “user_global.ino” is not working in this revision.

In the AC.h file, if you remove “#define LOG_ENABLE”, the logs will not be shown and the log memory would be released.

In the user_global.h file, you can change the bit-rate timing and delays with the following “define” variable:

#define AUDIO_6KHZ_DELAY%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; %26nbsp;%26nbsp;120
#define AUDIO_10KHZ_TIMING%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 97
#define AUDIO_15KHZ_TIMING%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 62
#define AUDIO_20KHZ_TIMING%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; 46

Also you can change the buffer sizes with the following variables.

#define AUDIO_BUFFER_SIZE%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp; %26nbsp;%26nbsp;%26nbsp;%26nbsp;%26nbsp;8000
#define AUDIO_NET_BUFFER_SIZE%26nbsp;%26nbsp;%26nbsp;%26nbsp; 100

  • If you have not enough programming and electronics knowledge, do not make changes.
  • The WiFi signal strength takes effect on the module capability and the streams.

- Compatibility of Camera devices for the Network feature
- Bugs fixed
- Network quality increased to 240kbps
- Online Audio stream added for the SpyCam devices in the network
- File manager upgraded
- VSPI mode added

- Memory card reader added to the hardware
- Voice recorder added to the software
- File manager added to the WebApp

- The audio noises reduced
- The network audio quality increased to 64Kbps
- Page loading speed increased
- Buffer size increased
- Connection secured with upgrading the secure link feature
- Auto network channel and target selector added

- The Web Ui upgraded
- Bit-rate and the quality of audio stream increased (240Kbps)
- Network stream feature added
- Network monitor feature added

- Bit-rate increased up to 110Kbps
- SecureLink bug fixed

- Schematic improvement
- The Web UI has been changed
- increasing the quality of the recorded sound
- Increasing the bitrate up to 100kbps
- reducing the noises
- Bugs fixed

- Schematic improvement
- Secure link debug
- ADC input improvement
- Output file improvement
- Selectable stream quality
- Adjustable stream time
- Adjustable software amplitude

- 10:28 frame (increased)
- Audio stream recorder and player
- 8KHz sample rate (increased)
- 10 bits resolution (increased)
- Calibration page
- The stability and quality of audio stream increased
- Suggested test circuit updated
- Bugs fixed

- 3300 miliseconds frames
- LOUD button
- 7.5KHz sample rate
- 8 bits resolution
- Internal pages secure link
- Show MAC and IP in config page
- Set module hotspot and modem’s ssid and password
- Automatically connection to the modem
- Config page
- Hidden hotspot button
- Disable hotspot button

i need to some explanation

Similar Projects: