1

I just bought a microphone for my Ardoino Nano 33 BLE. The mic can use both Analog and Digital input. Here is the mic and how it's connected. Mic and connection

Here is the code where I read the input

int sensorPin = A5; // select the input pin for the potentiometer
int sensorValue = 0;
void setup ()
{
 Serial.begin (9600);
}
void loop ()
{
 sensorValue = analogRead (sensorPin);
 delay (500);
 Serial.println (sensorValue, DEC);
}

I've followed an example by the manufacturer and the reads are going random between 0 and 5 sometimes a little higher. It states in the example that it should go up to 1023.

Is something wrong, can I have connected something wrong that would make this? Also when I give 5v nothing happens on the Mic but if I connect 3.3v the mic turns on 2 red led lights and gives me a value around 80 but doesnt respond to any sounds.

1
  • "There is also this 10K potentiometer that is used to set a reference voltage for the op-amp, also this potentiometer is used to generate the reference voltage for the analog out function of the module." - circuitdigest.com/microcontroller-projects/…
    – VE7JRO
    Commented Dec 13, 2022 at 18:14

2 Answers 2

3

/* edited to specifically provide a potential solution as commented by @jstola */

You have posted a picture of a ubiquitous sound detection sensor - typically a Keyes KY-037.

It is based on an LM393 dual comparator. LM393

The board has a digital output [marked DO] and an analog output marked AO. It also has + and G (Ground) connections. keyes sound board

I dug mine out and attached it to a Nano 33 BLT.

Nano 33 BLT with sound sensor

Notice that I have + connected to 3.3v, G connected to ground and AO connected to A5.

A little trick is to connect just power and ground and turn the potentiometer until L2 (that's the LED nearest the pot) turns off. If you make some noise, you will see L2 flash briefly. This sets the digital output threshold and works well for testing the analog out.

Then I ran this simple program (very similar to yours)

void setup() {
  pinMode(A5,INPUT); // not absolutely needed in this case
  Serial.begin(9600);
}
void loop() {
  Serial.println(analogRead(A5));
} 

Opened the Arduino IDE serial plotter (shift+ctr+L) and watched the waveform change when I snapped my fingers - see the spikes?.

serial plotter waveform

So what is the solution to your problem that is does not work?

A couple of possibilities.

  1. You have a different board.

Does your board look just like the one I posted or does it look different? If it is a different board then what you posted, that is another matter.

Assuming it is the same board (or at least the same generic board), it is possible that:

  1. You don't have the connections correct. Double check that.

  2. You don't have the pot set near the mid point - follow the direction for that and observe that the LED can be turned off. That is a multi-turn pot and if you hear a little 'click', you went too far in that direction - move it the other way and see if you can get that LED to just turn off.

  3. Failing any of those, your board could be toast

0
0

Welcome! This is generic in nature because you did not provide any links to the hardware items so everything is a pure SWAG.

I cannot properly answer your question without knowing what board you have, there are several that look similar in red and other colors. Maybe the following will help you determine what you have. Look at the specifications closely.

Your statement "The mic can use both Analog and Digital input." The mic is analog by nature but can be converted to a digital signal with an op-amp or comparator circuit as many of these modules have done.

It appears to me that your board will give you a logic 1 or zero, not an analog output. The pot on those generally sets the reference voltage for the comparator (may be an op amp) function, If it is a dual op amp the other half is an amp for the microphone. If there is an analog output the microphone signal needs to be amplified as the microphone output is only a few millivolts and the A/D needs volts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.