Sound Level Meter With Arduino

by jandb86 in Circuits > Arduino

1830 Views, 8 Favorites, 0 Comments

Sound Level Meter With Arduino

00_Overview.jpg

Previously three different versions of Sound Level Meter (From hereinafter as SLM) circuits are introduced.

All these circuits are mainly utilizing op-amps (NE5534, TL071) and LM3915 bar/dot display driver IC.

You can see the details of these SLMs in the following links.

***

https://www.instructables.com/Sound-Level-Meter/

https://www.instructables.com/Another-Sound-Level-Meter-Circuits/

***

These SLMs are well-performing as the pre-amplifier circuit's audio output voltages are closely matched with LEDs driving the threshold voltage of the LM3915 circuit.

But as these SLMs are pure analog circuits, there is not any chance of tweaking, modifying, or improving their functionality.

Also, the MIC, pre-amplifier, and LM3915 circuits are closely hardwired, any change of circuit component will directly impact the SLM functionality.

Therefore, I would like to change SLM operational scheme by utilizing an Arduino controller board.

As the Arduino board supports the sketch program as the main control functionality, you can customize SLM functionalities by modifying the control logic of the sketch program.

Also, the Arduino can interface with diverse peripherals with its analog ports (A0~A5) and digital ports (D2~D13).

In this Instructable, a new SLM-type device will be introduced by utilizing Adafruit MAX4466 MIC-amp break out with Arduino board.

Later I'll show how a previously made pre-amplifier circuit that uses NE5534/TL071 can interface with the Arduino board.

Let's look at more details about this new SLM device.

Schematics

01_Schematics.jpg

When you looked at the schematics of previous SLM circuits, the following analogy can be helpful to understand new schematics.

Actually, the Adafruit MAX4466 MIC-Amp board is the same as the pre-amplifier circuit.

It captures audio signals from the MIC and magnifies signal voltage with the MAX4466 amplifier IC chip.

Also, the Arduino Uno board supports LED display functionality which is covered by LM3915 IC with the previous SLM.

According to the captured audio signal voltage, certain LEDs are turned on by the sketch program stored on the Arduino board.

As input signal processing and LED blinking output is controlled by the sketch program, more custom-made SLM circuit can be made.

I'll show more details of the sketch program in the other step below.

The two 100K potentiometer's functionality can be cleared when explaining the sketch program later.

Parts

02_Arduino.jpg
03_MAX4466.jpg

The most important part of the SLM is the Adafruit MAX4466 MIC-Amp break-out board.

I used this board for making an audio amplifier as details are described in the following link.

 

https://www.instructables.com/Arduino-Audio-Sound-Level-Meter/

 

At the time the MAX4466 MIC-Amp chip is quite impressive because it can capture weak surrounding audio signals correctly.

But for making SLM, more clear audio input signal capturing is required.

Therefore, I’m plugging this board into the small PCB and locating it right in front of the speaker.

Anyway, as this new SLM circuit is completely different from the previous ones, the following different parts are used.

***

- Arduino Uno board, 5V

- Adafruit MAX4466 MIC-Amp board

- 10 LEDs (Blue/Green/Yellow(Orange)/Red) transparent 3mm high luminosity

- 330ohm 1/4W resistors

- 100K VR x 2

- Wires, Pin-head, Universal PCB

- Acrylic boards, metal PCB supporters

- Smartphone 5V charger

***

As the SLM functionality is relatively simple, initially I tried to use the smallest Arduino board (pro-mini) as shown in the picture above.

But the pro-mini needs an external sketch program writer as this board does not include USB serial communication chip.

Therefore, I used Uno board which unplugged the ATmega CPU chip as a program writer.

When the CPU chip is removed, the Uno board simply acts as USB serial communication device as shown in the picture above.

As all these inconvenient preparations are required for using pro-mini, I changed the main control board to Arduino Uno later.

For power supplying common 5V smartphone charger can be used as Uno and Adafruit MIC-Amp boards are operating at 5V.

Wiring and Soldering

04_Wiring.jpg

For making a prototype Arduino-based SLM, everything is packed together into (10cm width x 15cm length) acrylic board.

A female/male pin headers are used for mounting Adafruit MIC-Amp board on acrylic board.

Different from previous SLMs, this new one requires a digital signal processing function for the analog audio signal captured by the MAX4466 IC chip.

Although the MIC integrated into the Adafruit board support a powerful omnidirectional sound capturing feature, clear and strong audio signal input is necessary to support digital signal processing by the sketch program.

Therefore, the MIC should be located right in front of the speaker.

Even though captured voltage level is weak (less than 2V), the sketch program manipulates the low input voltage value to detect the correct level of sound strength data to drive LEDs.

Total 10EA LEDs are connected directly to the Arduino Uno digital ports. (D2 ~ D11)

As each digital port supplies 5V output, a current limiting resistor (330ohm) is inserted between LED and the Arduino digital port.

Digital Processing of Audio Signal With Two 100K VR

05_Level.jpg

The sketch program converts the input signal into the audio voltage value (0.0~4.99V) via the A1 analog port of the Arduino.

As the power supply voltage of the MAX4466 board is 5V, the output voltage can’t be higher than 5V.

As the MAX4466 board has a small voltage level adjusting VR, I fixed the VR value to the maximum range. (After setting the VR value, it should not be changed to fix the operational scheme of the MAX4466 board)

When locating the MAX4466 board right in front of a speaker, the narrow scale (0.0~4.99V) voltage level can be captured.

Subsequently, the small input voltage converted into audio signal level value (Multiplying 100 to the input voltage) becomes 32 ~ 499 (0.03 ~ 4.99V) as shown in the graph above.

These audio signal level values can be captured to a text file by executing the following command on Windows command prompt mode.

***

C:\ copy COM7 audio_input.txt

The above command is assuming the Arduino Uno board is connected to the COM7 serial port.

While running the command above, the Serial Monitor of Arduino IDE should be turned off. (Arduino serial monitor takes hold of COM port and other processes can’t access the COM port)

***

The audio signal voltages captured above are from typical content (Movie and commentary pop-cast programs) that I’m frequently viewing on YouTube.

From the graph above, the region enclosed by the red box is the most dynamic audio signal changing range.

It started from the base value of about 300 (0.3V) and a range (Gap) of 200.

When you divide 200 of gap range into 10 levels, all dynamic audio signal change regions (300~499) can be captured by 10 LEDs into 10 different signal levels like below.

***

Audio signal level 300~320 -> LED 1 (Green) turned on

320~340 -> LED 2 (Green) turned on

340~360 -> LED 3 (Green) turned on

360~380 -> LED 4 (Green) turned on

380~400 -> LED 5 (Yellow) turned on

400~420 -> LED 6 (Yellow) turned on

420~440 -> LED 7 (Yellow) turned on

440~460 -> LED 8 (Yellow) turned on

460~480 -> LED 9 (Red) turned on

480~500 -> LED 10 (Red) turned on

***

If you choose base as 100 in the graph above, the gap will become 100~300 range. (Audio signal change dynamics become flattened)

Then all the 10 LEDs are suddenly turned on at the same time or off together. (Signal pattern becomes less dynamic)

When more noise content is played (such as hip-hop songs), the base value will be increased by more than 300.

Then slightly higher base value (more than 300) capturing will be necessary.

For adjusting the base value range, VR #1 potentiometer is used.

By adjusting the potentiometer, the base value will be changed from 50 (Very quiet audio input) to 500 (Very loud and bomb exploding sound level).

If relatively quiet and less dynamic video contents are played (such as new, documentaries, and so on), the audio signal dynamic range (Gap) will be less than 200.

Therefore, narrowing the gap change from 200 (20 x 10 levels) to 100 (10 x 10 levels) shall be necessary. (By VR#2, adjusting gap range supporting potentiometer)

If you don't change the gap range (20->10), 10 LEDs displaying patterns become less dynamic.

That’s why I’m including two potentiometers in this new SLM circuit.

The Sketch Program

06_Sketch.jpg
07_Flow.jpg

For explaining the operation logic simplified flow chart is shown.

The audio signal receiving part is from the Adafruit reference program code.

The Adafruit code segment detects resistance change of the A1 analog port and converts peak-to-peak input value into input voltage. (0~4.99V)

According to the input voltage, the sound level value (level = volts * 100) is calculated.

Subsequently, the base and gap value is read from A2, and A3 ports to be summed to level.

As Serial.print() commands are inserted into the sketch program, values of the important variables (level, base, and gap) are printed on the serial monitor window as shown in the picture above.

According to the present setting, the base is fixed at 300 and the gap is 25 by two potentiometers.

Let’s assume the gap value is 20 for simplifying the overall explanation.

The 10 LEDs are indexed as 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 according to the hardwired digital port.

Therefore, the following LED lighting pattern is supported according to the input signal.

***

Let’s assume input voltage 3.1 (3.1V) ~ 4.65 (4.65V) during 300ms

Then levels are changed from 310 to 465.

Let’s assume VR2 (base) is 300 and VR1 (gap) is 20

During the 0~150ms time range, the following test command becomes true.

If (level > base(300) && level < base(300) + gap(20)*1) {

         pins = 2;

Subsequently, only LED 1 is turned on according to the following codes

For(int i=2;i<pins+1;i++) {

         digitalWrite(i, HIGH);

Then wait for 50ms by delay(50) to briefly show the present sound level.

Then turn off all LEDs.

During the 150~300ms time range, the following test command becomes true.

If (level > base(300) + gap(20)*8 && level < base(300) + gap(20)*9) { // level between 460~480

         pins = 10;

Subsequently, nine LEDs (2,3,4,5,6,7,8,9,10) are turned on according to the following codes

For(int i=2;i<pins+1;i++) {

         digitalWrite(i, HIGH);

Wait again 50ms (delay(50)) and turn off all LEDs

***

During about 1/3 second, one to nine LEDs are blinking to show the input audio sound levels (3.0~4.65V).

Likewise, the SLM continuously displays sound levels with 10 LEDs.

Downloads

Operating

08_operation.jpg

A similar SLM circuit (Using MAX4466 board) had been introduced in another Instructable which can be accessed by the following link.

 

https://www.instructables.com/Arduino-Audio-Sound-Level-Meter/

 

As the audio signal to digital data conversion control mechanism (such as two potentiometers controlling base and gap) was not used for the previous circuit, produced LED blinking patterns are highly dependable on the location of the amplifier and speaker.

Also displayed LED blinking patterns are slightly unmatched by the captured audio signal strength.

But with the revised new SLM, the operation scheme can be changed by two potentiometers.

Actually, VR2 (Base control potentiometer) supports macro control by selecting SLM activating baseline.

When an audio signal is weak (playing relatively quiet video/audio), the VR2 value can be reduced such as 250 to activate LEDs at a lower signal level.

In the meantime, the VR1 (gap) is the micro-level control mechanism.

When VR2 (base) is fixed, VR1 can change more or fewer LEDs are turned on to the same level of audio input signals.

Different from the previous analog type of SLMs (using pre-amplifier and LM3915), the new Arduino base SLM requires manipulation of the analog signal by digitizing input data.

Therefore, the new Arduino-based SLM’s operation can be a little bit artificial when illogical signal digitizing is happening.

But operation result is almost similar to previous SLMs as shown in the video below.

 

https://drive.google.com/file/d/1U6lMbh0tJgu-iCV2AG_76v_c_92J4WHf/view?usp=sharing

 

I’ll introduce another Arduino-based SLM variant in the next Instructables.

Thank you for reading this story.