Saturday, October 5, 2024

WLED: Analog vs. Digital Microphones

 



If you want your LED display to react to sound or dance to music, you will need to add a microphone to your WLED controller.  The audio-reactive version of WLED supports both analog and digital microphones.  Which should you use for your project?  This guide will explore both options.

A sound-reactive fork of WLED has been around since 2018, but it often lagged behind the official version and routinely had its own issues.  But starting with release 0.14.0 of the official WLED, an audio-reactive version can be installed.  


For now, this is considered a user mod, but the most recent beta version of WLED (v0.15.0-b5 as of the time of this article) includes audio-reactivity in the base version so a separate audio-reactive version is not shown as an option for installation.  If the production release of 0.15 does include audio-reactivity in the base image, some setup screens may be different than those shown here... which are all from the latest v0.14.4 version of WLED.

While there are many different types of microphones, this article is going to cover the most common options for both the analog and digital versions.  Comparisons, wiring and setup in WLED will be included.  However, to see side-by-side testing of the two microphones with music and other audio, please see the related YouTube video Analog vs. Digital: The Best Mic for Audio Reactive WLED

Parts List


As always, I like to start with a list of all the parts used or shown here or in the video.  For the ESP32, I'll show three different versions.  The differences are covered in the video but selection is primarily about how you wish to build the base WLED controller.  All three versions of the ESP32 work just fine with audio-reactive WLED and the microphones tested.

Important NoteThe audio-reactive version of WLED requires an ESP32.  It will not install/work with an ESP8266!


Item

Notes

ESP32 NodeMCU Style (30 pin)

Only one of the ESP32s needed

ESP32 Narrow (38 pin)

Breadboard friendly

ESP32 Mini

 

MAX9814 Analog Microphone

 

INMP441 Digital Microphone

 

Logic Level Shifter

Alternate: SN74AHCT125N

WS2812b LED Strip (100 LEDs/m)

 

WS2812b LED Strip (60 LEDs/m)

 

Half Size Breadboard

Solderable Option: ElectroCookie

Breadboard Jumpers

 

M-F Dupont Jumpers

 

JST Connectors

 

Pin Headers

 

USB-to-microUSB Data Cable

Only needed for initial WLED install

18 Gauge Stranded Wire

 

20 Gauge Stranded Wire

 

22 Gauge Stranded Wire

 

5V 30A Power Supply

Size depends on number of LEDs

AC Power Cord

 

Miscellaneous Wago Lever Nuts

 

 

 

Some of these links may be Amazon affiliate links.  Use of these links will not affect your pricing, but as an affiliate this channel may earn a small commission if you make a purchase.

The Base Controller


Both the analog and digital versions used for the comparison begin with a base WLED controller.

Click to enlarge

I won't be covering the step-by-step process of building the base controller here, but I have other videos and articles that will show you how to build a basic WLED controller; both a simple breadboard version and a soldered version:

Standard Wiring Diagrams (blog - various LED/WLED wiring diagrams)

The microphones will be added to these base WLED controllers, each installed with the most recent WLED production release (0.14.4 as of time of publication).

Microphone Comparison


As mentioned, there are many types of mics that are compatible and will work with the audio-reactive version of WLED, but I'll be using two of the most common and recommended mics:  The MAX9814 (analog) and INMP441 (digital).

 

 

MAX9814

 


INMP441

Type

Analog

Digital (I2S)

Operating Voltage

2.7 – 5.5 VDC

1.8 – 3.3 VDC

Typical Current Draw

0.5 mA

1.4 mA

GPIO Pins needed

1 (analog)

4

Cost*

$5 - $10

$3 - $7

 

 

 

*Costs will be dependent upon source and quantities purchased.

Even though the MAX9814 can handle 5V, I will be powering both devices via 3.3V.  The INMP441 is actually just a bit cheaper than the MAX9814, but costs will vary based on quantities purchased.  The other primary difference is that the MAX9814 analog mic only requires one GPIO pin (in addition to power/ground) while the INMP441 digital mic requires four GPIO pins.

MAX9814 Analog Mic Pinout and Wiring


Click to enlarge

GND:  Connect to any common ground point.  If you are using a breadboard (or ElectroCookie), you can create a power rail and use a ground connection there.  Otherwise, connect to any available ground pin on the ESP32.

Vdd: Again, 3.3V or 5V can be used.  I opted to connect to the 3.3V rail.

Gain: Three different gain levels can be set depending on whether you leave this pin unconnected (floating - 60dB), connect it to ground (50dB) or to Vdd (40dB).  The recommended setting from the WLED site is 40dB, so this pin will also be connected to 3.3V.

Out: This is the analog signal out.  It should be connected to any valid ADC1 pin on the ESP32.  I'm using GPIO32.  Important Note: Do not attempt to use any of the ADC2 pins.  These pins cannot be used for analog signals as the same time that WiFi is active.


AR: This is to set the Trilevel Attack and Release ratio.  Like gain, the value can be altered depending on whether this pin is left floating (not connected - 1:4000), connected to ground (1:500) or Vdd (1:2000).  For my install, I'm leaving it floating so this will not be connected to anything.

Configuring the MAX9814 Analog Mic


At least in version 0.14.x of WLED, the microphone settings can be found under the Usermods via the WLED Config menu.


Under Usermods, you should see a section for AudioReactive.  If you do not see this section, you may not have installed the WLED version with audio reactivity.  Flash WLED again with this option selected.  This may not be necessary with v0.15 and later as beta versions indicate that audio reactivity will be include with base installations.


For the MAX9814 (or other analog mic), you just need to enable the audio reactivity and set the GPIO pin you used for the Out on the microphone.  Note that only valid, unused pins are shown in the dropdown list.  If you attempt to use a non-analog GPIO pin or a pin that is already in use, it will not be available to select from the drop down list.

Prior versions of WLED required a reboot after making changes here, so it is recommended that you reboot the controller regardless.

INMP441 Digital Mic Pinout and Wiring


Click to enlarge

GND:  Connect to any common ground.  Again, if a power rail has been created you can use either ground rail connection.

VDD: The INMP441 has a max operating voltage of 3.3V, so it must be connected to 3.3V.  Do not attempt to connect to 5V or you may damage or destroy the microphone.

L/R: This controls whether the audio output is sent on the left or right frame of the I2S packet.  This is primarily used for stereo with dual microphones.  For WLED, only a single mono signal will be used.  L/R is connected to ground, which will use the expected left channel (connect to VDD to use the right channel).

GPIO Pin Selection:  For the remainder of the pins/connections, the select of a GPIO pin is somewhat arbitrary.  Most pins will work, but there are some exceptions.  If you want to know what pins are acceptable, go to the WLED interface for your controller and drop down the list under the audio reactivity setup and see the list of valid GPIO numbers (see below).

SD (Serial Data): I'm connecting this to GPIO15, but other pins can be used.

SCK (Serial Clock): I'm using GPIO14.

WS (Serial Word Select): I'm using GPIO32. 

Configuring the INMP441 Digital Mic


Again, in the current version of WLED, the microphone settings can be found under Usermods, accessible via the Config option on the main web page.


Similar to the analog mic, you must enable audio reactivity.  If an analog mic was used in the past (or a GPIO pin is specified for the analog mic), set this pin value to unused.  

Under the digital mic settings, set the type to Generic I2S for the INMP441. For other digital mics, drop down the box and select the appropriate mic type.  Set the SD, WS and SCK pin values to match your controller build.  The INMP441 does not use MCLK, so this should be unused.  However, if your mic uses the MCLK pin, set this value to match your connections.

After setting or changing any of these values, it is recommended that you reboot the controller.

Effects and Settings


Once you have defined a microphone and enabled audio reactivity, you will see a number of new effects and a filter box appear on the main WLED page.


In the effects list, you will see some that have a single eighth musical note (♪) which indicates the LEDs will react to the sound amplitude/volume.  Those with a beamed eighth note (♫) indicate sound effects that will react to frequencies.  Those without music notes are "normal" effects that can still be used, but they simply will not respond to sound from the microphone.

A filter box at the bottom of the effect list lets you filter the effects to only those that match a particular value... such as sound reactivity.

Once you select a particular effect, many have additional options that can be tweaked:


This may include things like frequency responses, fade rates, effect speed and more.  The settings will vary based on effect.

In addition, there are numerous general microphone settings that can be changed for best results under the Usermods page.


Values for things like squelch, gain, etc. will vary greatly depending upon your particular microphone, its positioning, type of music/audio source, etc.  You may need to experiment with various values to get the best response in your situation.  The original Sound Reactive WLED fork wiki contains some good information that may help you get started. Although this fork is now archived, much of the information provided in the wiki is still applicable to the current version of audio reactive WLED.

Comparison Results


While it is hard to physically show the difference in a written article, you can see how the different mics react in the related YouTube video, Analog vs. Digital: The Best Mic for Audio Reactive WLED but here are my general findings and thoughts:

  • The INMP441 Digital microphone provided much better, consistent and accurate results without requiring constant tweaking to settings such as squelch and gain.
  • The INMP441 had a much, much longer range for detecting sounds, easily picking up vocals or music from 30+ feet away.
  • The MAX9814 analog microphone was OK when placed close to a music or audio source, but different styles or tempos of music often required tweaking settings like gain/squelch for the best results.
  • When using an analog microphone, other analog controls (like potentiometers) may not work or work erratically.
As a general rule, the digital microphone provides a much better overall experience without impacting the use of other peripherals.  Note that the use of a digital microphone is also recommended by both the official and forked WLED sites.  As a general rule, the INMP441 is also slightly cheaper than the MAX9814.  The trade-off is that the MAX9814 requires only one GPIO pin vs. four for the INMP441.

Overall, adding a microphone to your WLED controller only costs a few dollars but provides a large increase in the number of effects and potential uses for your WLED display.  While the sound reactivity is probably more pronounced on matrix displays, they can also be used with linear strip displays. And note that adding a microphone does not remove any of the "normal" non-audio reactive effects you had before.  This makes it easy to go back and add a microphone to your existing WLED controllers (as long as you also update them to v0.14x or later of WLED).

Additional Information and Links



Supporting this blog and related YouTube channel


It takes significant time and effort (and occasionally expense) to create these articles and videos.  If you'd like to support future content on this blog and the related YouTube channel, or just say thanks for something that helped you out, you can consider buying me a one-off cup of coffee or two at:


No comments:

Post a Comment

To help eliminate spam and to keep all conversations civil, submitted comments are moderated. Therefore your post may not show up immediately. Please be patient as most reviews are completed within a few hours.