Not getting any Analog Values from Microphone Module

(Im really new to Arduino sorry in advance)

Im working on a project where I need the microphone module to send analog values for the sound "levels" to my computer. For some reason the module does not seem to be sending any values at all/not affecting the values I see in the serial monitor. What I do see in the serial monitor is a consistent 517. Does anyone know why this is? I'll provide any additional information if needed.

int micPin = A2;



void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
int micRead = analogRead(micPin);
Serial.println(micRead, DEC);
delay(1000);
}

Please do not post pictures of code. Instead, copy/paste from the IDE and insert into the post using code tags (<code> post editor button).

What would you expect to see, sampling audio for a tiny instant, just once per second, then printing at such a slow serial Baud rate?

Analog measure scale default is VCC, 5V on an Uno.
The Uno chip also provides an internal 1.1V reference that lets the ADC 0 to 1023 cover that 1.1V range instead of 5V.

Sorry, I edited the post as you said.

Changing the delay still results in the constant of 516/517 (Even with the delay set as low as 1). What serial baud rate do you suggest I use?

this module is audio trigger. it set output HIGH if sound encountered enough loudness

#define micPin  A2

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println(analogRead(micPin));
  Serial.flush();
}

then open serial plotter and watch while speaking in micro

2 Likes

This worked perfectly, thank you so much !

Try this code, which samples the pin as rapidly as possible (given the default settings) and reports the high and low values every so often. Values around 512 (or other midpoint) represent silence, or possibly, a nonfunctional microphone.

int micPin = A2;
int audio_min = 10000;
int audio_max = 0;
int count = 0;

void setup() {
Serial.begin(115200);
}

void loop() {
int value = analogRead(micPin);
if (value > audio_max) audio_max = value;
if (value < audio_min) audio_min = value;
count++;
if (count >= 5000) {
   Serial.print("min ");
   Serial.println(audio_min);  
   Serial.print("max ");
   Serial.println(audio_max);
  audio_min = 10000;  //reset min, max and counter
  audio_max = 0;
  count = 0;
  }
}

Those modules typically have two outputs, analog (A) and digital (D). The sensitivity of the digital output D can be adjusted by turning the screw on the rectangular blue box, which is a potentiometer.

You should connect to the analog output to use the analog input.

1 Like

thank you so much , the serial baud rate was indeed the issue and this code works as well, really appreciate it