sound sensor not working properly with esp32

kubo12345
Posts: 2
Joined: Sun Jan 01, 2023 2:22 pm

sound sensor not working properly with esp32

Postby kubo12345 » Sun Jan 01, 2023 2:32 pm

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);
}

bidrohini
Posts: 202
Joined: Thu Oct 27, 2022 12:55 pm

Re: sound sensor not working properly with esp32

Postby bidrohini » Mon Jan 02, 2023 3:04 pm

Make sure that you're connecting the sensor right.

bidrohini
Posts: 202
Joined: Thu Oct 27, 2022 12:55 pm

Re: sound sensor not working properly with esp32

Postby bidrohini » Mon Jan 02, 2023 3:16 pm

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.

kubo12345
Posts: 2
Joined: Sun Jan 01, 2023 2:22 pm

Re: sound sensor not working properly with esp32

Postby kubo12345 » Tue Jan 03, 2023 8:45 am

Iam sure i am connecting sensor right way and i already read that. I will try it on arduino as you said.

FRANCISCO2020
Posts: 21
Joined: Mon Sep 20, 2021 9:13 am

Re: sound sensor not working properly with esp32

Postby FRANCISCO2020 » Tue Jan 03, 2023 10:41 am

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.

Selraw
Posts: 1
Joined: Sat Dec 02, 2023 6:51 pm

Re: sound sensor not working properly with esp32

Postby Selraw » Sat Dec 02, 2023 6:59 pm

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

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: sound sensor not working properly with esp32

Postby lbernstone » Sun Dec 03, 2023 4:55 am

ADC2 is not available if you are using WiFi. ADC1 is on pins >32 on an esp32.

Who is online

Users browsing this forum: No registered users and 80 guests