Sound measuring device for mechanical LAB

Hi recently i've been assigned to make a device that will measure dB for the mechanical lab in my school and show the dB on a screen and also a warning alert for example: green between 0-50 dB, Yellow 51-85, Red 86-130 dB, i'm new into electrical/electronics, right now im researching on how to create the schematic, choosing components, and implementing all together in one PCB.

My expecations are to design atmega328p based custom designed board, with Wifi maybe bluetooth, Micro SD slot, the common pinout, a relay and boost converter to power the 12v leds i will be using, and maybe the Microphone and amp board int he same PCB but i don't know if it will be convenient.

I took the first step and bought some sound sensors from amazon (KY-038 schematic) i been doing several tests to know if it will be suiteable for my project only to discover they only will work with abrupt sounds like claps to turn on and off things or similar applications, but not valid ADC values to convert to dB

Then i came across the possibility to make that ky-038 module work using an amplifier circuit, using transistors, opamp's, audio amplifiers, With the complementary use of other components like capacitors and resistors. The only problem is that there is no explanation of the circuit designs i've seen, there's only the schematic but no clue why every component is used and what it works for, i tried to search separately for every one to get a better understanding but i fully still don't understand it. In some of them they were using LM358 and LM386 using both for same application.

So if anyone could be so kind to help me i will be very grateful. Either explaining to me, videos, articles, courses, anything that you think could help. With the first step of designing the circuit to use with electret microphone to measure dB and then, the design of PCB lenght, angles, width, proximity of traces etc.

I know it will take a long time to learn those things but i will put all my effort to make this project happen, i usually don't post things like these even tough after researched and read many things across the internet but i feel i haven't crossed with the right information so that's why i came to you for help.

Thank you in advance

This can be done, but there are a couple of things that make it "difficult".

Anything 'homemade" can't be calibrated/validated by an independent calibration lab so it's not valid for legal or regulatory purposes.

The other tricky part is the [u]A-weighting[/u]. You may be able to approximate that with some analog filtering, or if the "nature" of the noise is fairly constant, you can ignore it and your readings should be "close" as long as you've calibrated with a real SPL meter.

You can buy a [u]microphone board[/u] complete with a microphone, preamp, and biased output (needed because the Arduino can't read negative voltages). These things are quite linear (as long as you have a strong signal-to-noise ratio and as long as you don't overload it).

There are 3 kinds of microphone boards. A "standard" microphone board will give you an (biased) analog representation of the sound waves (just like the audio signal from a microphone preamp, except for the bias). You "sample" the analog waveform and then you can find the peak, average,* or RMS value.

Some boards have a peak detector (envelope follower) which gives a DC voltage proportional to the peak sound level. That's easier to use, but the peak may not be as useful for "loudness", depending on the nature of the sound.

Some boards have a digital output that goes high when the sound level exceeds a preset (adjustable) level. That's no good for you because you need 3 different levels.

You'll have to calibrate your setup with a real SPL meter. "All you need" is a reference ADC reading at a known reference SPL level. Then you can calculate the electrical/digital dB difference from that reference to find the associated dB SPL for any signal level.

For example, let's say the ADC reads 1000 at 100dB SPL (which you find experimentally). If the ADC then reads 500, that calculates to -6dB relative to 1000. So, you now have 94dB SPL.

  • The true average of an audio waveform is zero, or with the bias the average is equal to the bias. But you can take an average of the positive values (after subtracting-out the bias) or you can take an average of the absolute values.

The big big problem here is that you are trying to fly before you can crawl. Learning electronics is a cumulative process with lots of very simple things building on themselves.

recently i've been assigned to make a device ....

Who gave you this assignment, is it educational and if so what are you studying? I would say whoever gave you this does not understand what is involved. What is your time scale? Starting from scratch I would guess you need about three years.

My expecations are to design atmega328p based custom designed board,

Way way too much for a beginner, the best you can hope for is to string existing modules together on strip board and you will struggle with that.

The only problem is that there is no explanation of the circuit designs i've seen, there's only the schematic but no clue why every component is used and what it works for,

You won't find this level of detail on a complex project, because it would be so tedious to write and even more tedious for 99.99% of people to read. Also so much of the contents would be repeated from project to project.

In some of them they were using LM358 and LM386 using both for same application.

Unfortunately the internet is full of tutorials written by idiots who barely understand the subject themselves. They cobble something together that appears to function and they rush to publish it on line where there is no quality control at all. If youlook at the data sheet for these devices ( just google the part number ) you will see the LM358 is a Low Power Dual Operational Amplifiers and the LM386 is an audio power amplifier. There is no way that these two devices are suitable for the same application.

You can't expect to learn it all in one go and then build things.

Forget about dBs for the moment, just get an analogue signal of the correct level and display the numbers from the A/D converter in the serial monitor window. Look for audio projects like http://interface.khm.de/index.php/labor/experimente/arduino-realtime-audio-processing/ but even this will be too advanced unless you learn the basics of electronics. A good book is :- https://artofelectronics.net/ It is a very big book but has good solid information and is built up slowly.

If there is something you don't understand in it the you can always ask here.

Oh and get yourself access to an oscilloscope and learn how to use it.

I agree that it will be a long way to go for you. The choice of an 8 bit Arduino shows lack of knowledge about algorithms for sound analysis. Likewise ignorance of electronic parts and circuits doesn't fit together with a wish of rolling your own PCB. Which "dB" do you want to measure, according to which standard? Properly measuring sound is a science of its own, not a feeling.

Did you ever look at Wikipedia "Loudness monitoring", as a headstart, and the referenced documentation? Start a broad search for all related topics, before you dig into details like amplifiers, controllers, WiFi and PCB design.

Until then you may get an Arduino Starter Kit and build your own Knock Lock (#12). Start with a single LED of each color, before you add a power supply and amplifiers for bigger displays. For SD cards, WiFi or BT you better select an Arduino with all that on board. The same for a microphone and (pre)amplifier module as a replacement for the piezo.

The quickest route would be to buy an Arduino compatible factory calibrated sound level sensor.

e.g. DFRobot Analog Sound Level Meter

This leaves you with the problem of interfacing to whatever display is desired and doing the data logging bits. Tutorials for both are readily available.

This presupposes that the objective is to get a working device rather than to demonstrate competence in low level mixed signal electronics design.

1 Like