KY-038 Reading 0

Hi,

I'm using a KY-038 microphone, in analog but I am only getting analogRead values of 0.
I have the A0 pin on the sensor connected to A0 on the arduino, G connected to a ground port and + connected to the 5V. If anyone could see why this is happening it would be appreciated cheers.

My code is below:

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

void loop() {
  // put your main code here, to run repeatedly:
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
}

It looks like it's wether a defective unit or bad wirings, that's a pretty straightforward connection and code.

Have you checked the cables? Are you using a breadboard and/or Dupont cables?
Could you add a picture of the wirings?

And have you tried to check the digital output also? Check this, just in case...

There is a variable POT on the PCB. Did you try to adjust that?

Have you tried shouting down he microphone?

See this link

That's primarily for the digital output, and is a 10k pot connected from the mic output and Vcc so I think it can't actually bring AO permanently to GND.

You can see from the above circuit that there is no amplification of the analogue audio signal. It is straight from the microphone. This is a tiny voltage, way too small to make any impact on the analogue input of the Arduino.

The Aout signal needs to go through an amplifier before you can read it on an Arduino. So what you see is exactly what you would expect to see.

The LM393 is not an amplifier it is a circuit called a comparator. It makes the output a high or a low depending on which of its two inputs are a higher voltage only by a smigen.

1 Like

Yes, it isn't amplified in any way, but are you sure it's needed? I don't have a KY-038 right now, but I see there's a pullup (via the 10k trimmer) making it like a partitor, and many example codes I have found around where there's no mention of any additional amplifier/tranistor.
Like this, just to link one, and tested with the following analog output code:

int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
 
void setup () 
{
  pinMode (ledPin, OUTPUT);
  Serial.begin (9600);
}
 
void loop () 
{
  sensorValue = analogRead (sensorPin);
  digitalWrite (ledPin, HIGH);
  delay (sensorValue);
  digitalWrite (ledPin, LOW);
  delay (sensorValue);
  Serial.println (sensorValue, DEC);
}

If OP using such code can't get any significant value from his device, I suspect either he needs to check the sensitivity trimmer, or it's defective, or some bad wiring.

Yes.

That is because there is a lot of rubbish out there that hasn't ever been tested. If you try that code you will get exactly what the OP saw.

I know we find a lot of rubbish around the net, and based on a better look at the schematic you're right. I still wonder why he always gets zero from analogRead (I expected some fixed values depending on the trimmer setting, and not zero as AO isn't brought to GND) anyway.

Said that, then the only directly usable pin is the digital one. What confused me is that in the past I remember I used that device but just once, and used DO because I just needed to detect sounds exceeding a specific amplitude (but I don't have it anymore so I can't make more tests).

So, if the OP doesn't really need to capture sound level but just detect noise levels (like a clap, just to say) he could use DO instead of AO (and obviously digitalRead instead of analogRead).

Otherwise, he needs a mic preamp like MAX4466 but at this point using the KY-038 just to use its mic is kinda useless IMHO. :wink:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.