Sound detector - signal amplification

Hi, i have a sound sensor board which works but doesn't seem to work very well. I've had the exact same problem with another version from adafruit.

I have a moving average sketch (100 readings @ 1/10th second delay for a complete update at 10 seconds). This sketch seems to work fine and performs as it should with a potentiometer and even the sound meter. The problem is the sensitivity of these meters.

I've turned the built-in gain so that the moving average settles at ~130. Nothing I do, except blowing directly into the mic will cause any change. But no matter how I hard I blow, the reading is no larger than 170. And they definitely not quite response to my clapping or voices or anything else.
So I wonder is there any way to significantly increase the sensitivity of sound sensor? I've played with the extremes of the internal gain to no avail.

I am willing to build, buy, and solder anything to get this thing sensitive enough that it responds to general room noise.

Thanks all.

When you sample an audio signal at 10Hz, the bandwidth of the signal must be no more than 5Hz. Blowing on the mic or clapping will generate much higher frequency components than 5Hz. For example, think about what happens when you clap. The duration of the clap could be quite a bit less than 1/10th of a second, in which case you sampling is unlikely to even detect it. If you want to react to something as abrupt as a clap, get rid of the running average altogether.

Pete

Post your code (in code tags).

Pete

//Sorry I’m not sure what Code tags are, but this is the code. Pretty much copy-paste from the template.

const int numReadings = 100;
int readings[numReadings];
int readIndex = 0;
int total = 0;
int average = 0;
int inputPin = A0;

void setup() {

Serial.begin(9600);
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}

void loop() {

total = total - readings[readIndex];
readings[readIndex] = analogRead(inputPin);
total = total + readings[readIndex];
readIndex = readIndex + 1;

if (readIndex >= numReadings) {
readIndex = 0;
}

average = total / numReadings;
Serial.println(average);
delay(100);
}

Pete, i’m open to other solutions, as I’m only a week into this Arduino business and have super nascent ideas about what is (and isn’t) possible.

What I’m trying to do is read a rooms noise, smoothed over some time (say a 5 minute average), and have the sound level dB normalized (can be buckets really: 0-10, 10-20…70dB+) so that they direct a linear actuator to extend or contract such that its position matches to the corresponding noise level.

Thanks

Read How to post code properly and then use the </> icon to create

[code]...[/code]

tags around your code so that it is easier to read.

Pete

const int numReadings = 100;
int readings[numReadings];      
int readIndex = 0;              
int total = 0;                 
int average = 0;               
int inputPin = A0;

void setup() {
  
  Serial.begin(9600);
  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }
}

void loop() {

  total = total - readings[readIndex];
  readings[readIndex] = analogRead(inputPin);
  total = total + readings[readIndex];
  readIndex = readIndex + 1;
  
  if (readIndex >= numReadings) {
    readIndex = 0;
  }

  average = total / numReadings;
  Serial.println(average);
  delay(100);       
}

What I’m trying to do is read a rooms noise, smoothed over some time (say a 5 minute average), and have the sound level dB normalized (can be buckets really: 0-10, 10-20…70dB+) so that they direct a linear actuator to extend or contract such that its position matches to the corresponding noise level.

Many people have tried to do this sort of thing and they all have failed.

This is mainly because the perceived noise is not well related to the measured noise. I remember several years ago some one trying to measure how noisy their school canteen was and when it exceeded some threshold a “please be quie “ sign would light up. Six months of fiddling with averaging and thresholds failed to find a soloution. At best this is a lot more difficult than you think.

(can be buckets really: 0-10, 10-20...70dB+)

dB is a logarithmic scale, and you are attempting to measure and average tiny slices of the ambient sound on a linear scale. That approach certainly won't capture a hand clap.

The 10 bit Arduino ADC barely covers 0-60 dB in voltage ratios.