Arduino & MAX9814 – Getting Started!

This post discusses how I integrated a regular microphone into an Arduino setup for some serious audio experiments. I used a prewired module which holds a MAX9814 single chip microphone amplifier with automatic gain control to prevent clipping and a low-noise microphone bias convenient for use with common electret condenser microphones. For a detailed explanation on how to use this little chip, see the MAX9814 datasheet published by Maxim Integrated Products, inc. https://datasheets.maximintegrated.com/en/ds/MAX9814.pdf

The MAX9814 module is a fancy microphone amplifier module. It comes with a 20-20kHz electret condenser microphone (ECM) soldered on, and has a few options the user can configure. The default maximum gain is 60dB, but can be set to 40dB or 50dB linking the Gain pin to Vdd or GND. The Attack/Release (EN) ratio, from the default 1:4000 to 1:2000 or 1:500 can also be changed. The final audio signal output from the module is about 2Vpp maximum on a 1.25V DC bias. Below are its key specifications:

  • Automatic Gain Control (AGC)
  • Three Gain Settings (40dB, 50dB, 60dB)
  • Programmable Attack Time
  • Programmable Attack and Release Ratio
  • 2.7V to 5.5V Supply Voltage Range
  • Low Input-Referred Noise Density of 30nV/√Hz
  • Low THD: 0.04% (typical)
  • Low-Power Shutdown Mode
  • Internal Low-Noise Microphone Bias, 2V
  • -40°C to +85°C Extended Temperature Range

Quick Note: The MAX9814 module’s output is not 0V in idle state as it has a 1.25VDC offset!

The following figure shows how to connect the MAX9814 module and your Arduino Uno board to cook up a quick evaluation setup. All you need here is just three jumper wires!

Quick Note: This library can control the gain level and attack/release ratio of MAX9814 https://github.com/alislahish/Alislahish-MAX9814. Go to the examples folder for code you can run with an oscilloscope and some MAX9814 modules to see the difference in waveform characteristics when you use different gain modes. If your oscilloscope displays measurements onscreen, try turning on Vpp while running the example code.

First, I picked a simple code I tried before (to test golf ball surveillance surveillance microphones at that time) for this quick evaluation, and it worked out well!

[code]

const int sampleWindow = 50; // 50
mS Sample window width (20Hz)

unsigned int sample;

void setup()

{


Serial.begin(9600);

}

void loop()

{


unsigned long startMillis = millis(); // Sample Window Start


unsigned int peakToPeak = 0; //
Pk to Pk Level


unsigned int signalMax = 0;


unsigned int signalMin = 1024;


// collect data for 50 mS


while (millis() – startMillis < sampleWindow)

{


sample = analogRead(0);


if (sample < 1024) // Cast out
spurious readings


{


if (sample > signalMax)


{

signalMax = sample; // Save just the MAX levels


}


else if (sample < signalMin)


{

signalMin = sample; // Save just the MIN levels


}


}


}


peakToPeak = signalMax – signalMin;
// MAX – MIN = PP Amplitude


double volts = (peakToPeak * 5.0) / 1024; // Convert to Volt


Serial.println(volts);

}

[/code]

And so, we come to the MAX9814 electret microphone amplifier with auto gain control module which costs below $10. As per its datasheet, this minuscule module will work with a supply voltage from 2.7 V to 5.5 V. In addition to the power (Vdd) and ground (GND) terminals, we have an audio output (Out), a gain control input ( Gain), and an attack/release ratio control input (EN).

As you may recall, leaving the AR pin unconnected means we use the default attack/release ratio of 1:4,000. Pulling this pin to Vdd or GND allows us to change the attack/release ratio to 1:2,000 or 1:500, respectively. Likewise, if we leave the Gain pin unconnected, then the default gain will be 60 dB (1,000), if we connect this pin to GND (0V), the gain will be 50 dB (~316), and if we pull this pin to Vdd (5V), the gain will be 40 dB (100). So, in addition to the internal automatic gain control (AGC), we also have the ability to tweak the gain to certain extents!

Below you can see the MAX9814 module’s schematic (Thanks Adafruit). Note that the microphone is a standard omnidirectional electret microphone which requires a 3V bias above a 2.2KΩ resistor in series with the microphone and connected to ground. The microphone itself has a typical output impedance of 2.2KΩ, and 0.5mA of current consumption. This is the datasheet of the electret microphone CMA-4544PF-W (CUI DEVICES) https://www.cuidevices.com/product/resource/cma-4544pf-w.pdf

MAX9814 + Arduino Clap Switch?

I bought this module to make a simple clap-triggered toggle switch that’s able to work in very noisy environments, and in situations where the intensity of the audio signal isn’t easily foreseeable. Below is the prefatory code of the Arduino Uno/Nano Blow Switch.

void setup() {

//Serial.begin(9600); // Start Serial for Debugging @9600 Baud

pinMode(LED_BUILTIN, OUTPUT); // D13 as Drive Output

}

void loop() {

int analog_val;

static bool led_state = false;

analog_val = analogRead(A2); // A2 as Signal Input

if (analog_val > 480) { // Threshold Value – Tweak Yourself!

if (led_state) {

led_state = false;

digitalWrite(LED_BUILTIN, LOW); // Drive Output = OFF

//Serial.println(analog_val);

}

else {

led_state = true;

digitalWrite(LED_BUILTIN, HIGH); // Drive Output = ON

//Serial.println(analog_val);

}

delay(1000); // Halt for a while

}

}

Below you can see a quick snap of its basic test setup (Powered by a 6F22 9V Battery).

Quick Note: the threshold value (480) used in my code may not be exactly correct for you, and you should of course change it to harmonise with your hardware setup.

Next is the schematic diagram of my first execution. No driver circuitry has been wired from D13 yet as the inbuilt LED is sufficient to test the code!

From where I stand, the MAX9814 module will be a good choice for above-average audio projects, as it can provide a more sensible audio signal that most analog-to-digital converter circuits will welcome.

As a final thought, I’ve toyed with the idea of ​​replacing regular electret microphone modules with advanced analog and digital MEMS microphone (https://www.edn.com/basic-principles-of-mems-microphones/) modules. So, in a later post, I’ll get into the details of doing audio capturing from a MEMS microphone. The upcoming part is where things get more interesting because maybe then we will go to the magical world of the Inter-IC Sound (I2S) Bus (https://www.cypress.com/file/133906/download) 🚀

Leave a Comment