Electronic – How to hook Raspberry Pi with Electret Microphone to detect sound levels in dB

adcelectretpythonraspberry pisound

I have to detect sounds levels in an enclosed area, so I thought this could be the right choice.

/*EDIT
I wish to collect sounds levels of about 30-60dB, normally human conversations or just environmental noise. What I really want to achieve with this is to collect sounds that may be noticeable to humans.
*/

I purchased an Electret Microphone with Auto Gain from Adafruit https://www.adafruit.com/product/1713

I am trying to interface it with a raspberry pi 3 to detect sound levels, however, I have not been able to find a solution for it as most of the tutorials are for Arduino or other breakout boards, does anyone have a solution for this?

Understood that the output from the microphone is analog typed and I have an adc converter ADS1115 and MCP3008 that would be useful, but I have not been able to search for the solution that would guide me on using the microphone and the converter.

//EDIT I have been able to hook the sensor to the ADC and MCP, however, the values stay constant and do not seem to change at all, even playing songs into the microphone do not change the values. I get a constant value ranging from 200 to 300 on MCP and around 1056 on ADC.

Followed tutorials on https://learn.adafruit.com/adafruit-microphone-amplifier-breakout/measuring-sound-levels
but I need to output them in decibels on RPI, I need to send the data to a server.

I have been using Adafruit's libraries on MCP3008 and ADC1115, am I doing this wrongly?

I need to collect the sound levels in decibels and put them up into a server.

Cheers

Best Answer

You selected a microphone board with automatic-gain. This is exactly the OPPOSITE of what you need. You can not measure the actual audio levels when there is something upstream UN-doing all the audio level changes ("auto-gain"). So first, you must use the proper microphone module that will deliver the actual, honest, un-modified audio levels to you.

Second, you are trying to measure audio LEVELS, not the actual audio WAVEFORM itself. That means you need to average or integrate the audio signal to produce the "envelope" of the audio levels. You can do this in software by sampling the audio at some high rate and furiously do mathematical calculations, or you can do this much more simply in hardware by rectifying and integrating the audio signal into a moving DC signal which represents the audio LEVEL at any particular moment. Then you can sample and scale this varying DC into deciBels or whatever.

I would very strongly recommend getting a microphone board essentially designed to do exactly what you are proposing. Namely the Sparkfun Sound Detector board. This board has the electret microphone capsule, and also the mic preamp, and a peak detector and an output buffer amplifier. All you need to do is connect the peak detector output from this board to an analog input pin on your Arduino and you have the audio envelope delivered to you on a silver platter. Easy-peasy.

Example: https://www.sparkfun.com/products/12642