ESP Spy Microphone

Electronics and Programming tutorials and projects

ESP Spy Microphone

esp spy microphone

Here is another update for the “ESP Spy Microphone” project which is ESP8266/NodeMCU and ESP32 WiFi microphone arduino source code, revision 1.5.

In this update I have increased the audio stream recorder sample rate to 240KHz for both of ESP8266 and ESP32 firmware.

Also the new feature is the “Chain Network” which is a local network that the devices one by one are connected to the each other and can transfer the audio stream data to the “Web Application”.

The latest update, revision 2.0 is available in the following links:

ESP8266/NodeMCU Network WiFi Spy Microphone Arduino Source Code – Rev 2.0

ESP32 Network WiFi Microphone Arduino Source Code and Schematic – rev 2.0

There are the following files in this project:

  1. ESP8266WiFiMicrophone.ino/ESP32WiFiMicrophone.ino (Main handler file)
  2. AC.h (Configuration header file)
  3. AC.ino (Configuration handler file)
  4. functions.ino (System functions)
  5. rootPage (UI handler file)
  6. user_global.h – Project global variables and definitions file.
  7. user_init.ino – Project initial script file.
  8. user_loop.ino – This file has a “userLoop()” function which calls repeatedly (like arduino “loop()” function).
  9. user_settings.ino – Project settings file.
  10. user_main.ino – Audio player handler script.
  11. user_sub.ino – Network monitor handler script.
  12. user_global.ino – This file has a “userGlobal()” function which calls at the same time in all of the devices in the network. This function will be called when the app sends a command to the network (after userMain and userSub).
  13. Webapp.h – This file contains the WiFi ECG WebApp’s script.

This project is compatible with ESP8266 modules which have ADC pin, like ESP-12-E and ESP8266 NodeMCU.

ESP Spy Microphone Web Application

wifi microphone mobile app

The circuit with “NodeMCU” and “Waveshare Sound Sensor”:

nodemcu wifi microphone

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

esp32 wifi microphone

WaveShare Sound Sensor

WaveShare sound sensor is an audio amplifier and sensor with LM386. This module is compatible with this project.

waveshare sound sensor wifi microphone lm386

ESP WiFi Spy Microphone Schematics

It’s suggested to use a standard 3.3V microphone module (like “WaveShare Sound Sensor”) for ESP Spy Microphone. The ADC pin (A0) of esp8266 is the audio signal input. Before using the WiFi microphone, build one of the following circuits.
Here’s a suggested circuit with a simple capacitive microphone, LM386 and ESP8266MOD (ESP12):

esp8266 wifi microphone shcematic

In the above schematic (LM386 and ESP8266MOD), LED1 shows the power is on, SW1 is the ESP8266 module reset button, H1 is the module’s UART connector (for flashing/programming) and H2 pin header needs a jumper to put the ESP12 module in the flash programming mode.

The microphone block has a potentiometer (P1) to calibrating the input audio signal. In the low level, the audio noise will decrease but the output audio is weaker and in the high level you can hear the small voices but more noisy.

  • Better to use a 5-12V power source with 2A output drain capability.
  • The module must only receive 3.3v (from the LF33 regulator). Higher voltage will hurt the module.

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 esp spy microphone shcematic

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 and ESP8266 WiFi Microphone Web Application

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

Then in case you are using ESP12 or ESP32, 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 of ESP Spy Microphone:

wifi esp spy 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 esp spy 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.

The Settings menu

The web application’s settings menu has been divided to 5 parts:

  1. Modem Configuration
    In this section you can see the available access points, the connection status, the device MAC address and the DHCP IP.
    Also in this section you can set the SSID and password of the modem’s access point.
    If the modem is not available, clear the SSID text box and save it.
  2. Device Hotspot Configuration
    In this section you can set your module’s hotspot SSID and password.
    The secure link is a string which will be added at the end of your module’s IP address. For example if you set it “123”, the IP address of the WebApp of your module will be instead
    The even means the default IP is, the Odd means the default IP is
    Hidden HotSpot will set the HotSpot hidden.
    Temporary HotSpot will disable the HotSpot right after the module is connected to the modem or joined to the network (For the last device in the network).
    The SSID must be without space in case you’re going to join the device to the network.
  3. Microphone Configuration
    In this section:
    You can set the device’s network channel. The channel must be a number between   0-7 and the devices can’t have the same channel.
    The “Audio Stream Sample Rate” can be 12, 18 or 24 KHz.
    The “Audio Stream Packet Length” can be 5, 10, 30 or 60 minutes.
    The “Audio Stream Resolution” can be 8 or 10 bit.
    For 240Kbps, set the sample rate to 24 KHz and resolution to 10 bit.
  4. Local Network Configuration
    In this section you can set the “Master” device and also set the userGlobal() function execution delay.
    The linked WiCard IP is the IP of linked device to the module’s access point.
    If you don’t turn on the “Join Required” switch, the module will be set as Master
  5. Local Network Map
    In this section, the attached devices in the chain network will be shown.
    For the master, it starts with master’s SSID, then the second ESP device, until the last one, but for the last device, the sort is vice versa.
    With typing the target device SSID in the target text-box, the oscilloscope will show the target device signal.
    Both of ESP32 and ESP8266 can transfer the audio data of the other modules in the network.

ESP Spy Microphone 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            140
#define AUDIO_12KHZ_TIMING        80
#define AUDIO_18KHZ_TIMING        54
#define AUDIO_24KHZ_TIMING        39

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

#define AUDIO_BUFFER_SIZE              3900
#define AUDIO_NET_BUFFER_SIZE     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.

The ESP Spy Microphone projects are available in the following:


2 Responses

  1. Sergey says:

    Need support i2c microphone ICS-43434

    • WiCard says:

      Currently the project reads the analog data directly from the ADC pin, but you can add this feature in the script.

Leave a Reply

Your email address will not be published. Required fields are marked *

14 + 1 =