Page 1 of 1

sound sensor not working properly with esp32

Posted: Sun Jan 01, 2023 2:32 pm
by kubo12345
Hi, I am trying out sound sensor KY-037 and all i want to do is to print analog values. Seems pretty simple but i always get 4095 as output and i am starting to think that sensor is broken. Iam using esp 32 doit-devkit-v1

Code (using VS Code, PlatformIO):

Code: Select all

#include <Arduino.h>

void setup() {
  pinMode(2,INPUT);
  Serial.begin(9600);
}

void loop() {
  float x = analogRead(2);
  Serial.println(x);
  delay(200);
}

Re: sound sensor not working properly with esp32

Posted: Mon Jan 02, 2023 3:04 pm
by bidrohini
Make sure that you're connecting the sensor right.

Re: sound sensor not working properly with esp32

Posted: Mon Jan 02, 2023 3:16 pm
by bidrohini
Here is a diagram that you can follow: https://diyi0t.com/sound-sensor-arduino-esp8266-esp32/
If it does not work, you can test your sound sensor with an Arduino. Connect the sensor to the Arduino and make noise in front of the microphone by shouting or clapping. If the value does not change, perhaps, you got a bad sensor.

Re: sound sensor not working properly with esp32

Posted: Tue Jan 03, 2023 8:45 am
by kubo12345
Iam sure i am connecting sensor right way and i already read that. I will try it on arduino as you said.

Re: sound sensor not working properly with esp32

Posted: Tue Jan 03, 2023 10:41 am
by FRANCISCO2020
Some things you can check:

Make sure you are connecting the sensor to the corresponding pin. In this case, the sensor is connected to pin 2.

Be careful not to confuse the count of pin numbers, with the actual In / Out assigned to each pin.

Verify that you are using the analogRead() function correctly. This function takes one argument which is the pin number to which the sensor is connected. In this case, the argument is 2.

Make sure the sensor is getting enough power. If you are using an ESP32 board, make sure it is connected to a suitable power source.

Verify that the sensor is connected correctly. Make sure the cables are firmly connected to the sensor and the board.

If the sensor continues to give incorrect values, it could be damaged or defective. In this case, you could try another sensor to see if the problem is with the sensor or some other component.

Re: sound sensor not working properly with esp32

Posted: Sat Dec 02, 2023 6:59 pm
by Selraw
I have the same issue here.
analogRead(AUDIO_IN_PIN); // always return 4095

when I connect a potentiometer I see 0 to 4095 no issue but the microphone seems to stay at 4095 whatever sound input is received.
There is an LED on the microphone board and it reacts to sound accordingly.

Any luck on your side?
Thanks

Re: sound sensor not working properly with esp32

Posted: Sun Dec 03, 2023 4:55 am
by lbernstone
ADC2 is not available if you are using WiFi. ADC1 is on pins >32 on an esp32.