Extracting the raw sound waves

Did you know that humans have a hearing range between 20Hz and 20kHz? and even the fact that as we grow older our hearing becomes weaker and we begin to loose the ability to hear higher frequencies?
Well, when it comes to the technicalites of sound waves there is so much to it than just frequencies and loudness. Audio signal processing is a really big and interesting thing to delve in.
 In this piece we are going to use a sound sensor to retrieve some raw sound waves with the help of an Arduino UNO, and we’ll build a simple loudness meter with the data we get.

Sound waves

Sound waves are actually longitudenal waves, but most of the time we prefer to represent them as transverse waves for easy understanding and analysis. With every transverse wave we have properties like:

  • Amplitude
  • Wavelength
  • Period
  • Frequency
  • Velocity or speed
Dont worry if you know nothing about these yet. In this tutorial the data that will be extarcted from the sound sensor will be ploted on a live graph for you to see.
Lets get the KY-038 sound sensor circuit ready for extraction.

The Ky-038 sound sensor module

This is the sound sensor module we are using here. It comprises of a microphone and a simple processing circuit that helps us to retrieve both analog and digital readings from the microphone. We will be making use of the Analog pin rather than the digital pin in this tutorial. You can grab one of these sensors from the Aaenics Store.

Note that the sensitivity of the sensor is adjusted by tuning the potentiometer on it. 

The Circuit

So as you can see, you should be able to set this up in less than 5 mins. The important things to know is that:

  •  You need to conect the Analog output of the sensor to any of the analog pins on your arduino board.
  • You need to power it with 5v for effectiveness.
  • And the RGB anodes of your 3 in one LED shoud also be connected to different digital pins. 
  • You can also use seperate LEDs or even more LEDs if you want to further customize it. Just dont forget to implemt the changes you make in the codes too.

Sound Loudness Meter

So what this setup hopes to achieve is just to serve as a sound meter. A way to read and caliberate the loudness of the sound read from the sensor.  In this particular setup, the red, green and blue LEDs are triggered to come on when the sound levels are within some ranges we will set in the codes.
When there is sound but not loud enough, the green LED comes on
When there is sound and it is a little bit loud, the blue comes on
When there is sound and it is very loud, the red LED comes on.

This will continue to be the reaction over and over when you are speaking or playing some music.

See the Sound waves on a graph

When you read the analog values coming out of the sensor on the serial monitor, you will see the numbers changing as you speak, but you won’t really appreciate the sound signals or waves until you view it from the serial plotter of the arduino.
It automatically plots the intensity of the sound on the y-axis and plots real time on the x-axis. Very cool for analyis. You can open the serial monitor by going to Tools>>>Serial Plotter

When you are not speaking, you will see almost a straight line at a certain level depending on where you have tuned your potentiometer to. It is the values at this point and around this point which you will need to use to caliberate your sensor for use in the codes. Copy the codes below, upload to your system, and check how the different sound levels affect the graph and use the information to personalize and caliberate the sensor and the LED effects…..
When I was working on this tutorial, my potentiometer was set to give normal reading around 106.0 so my calibration started from 105 downwards, change the codes to suit yours too.

Sample video of sound loudness meter with RGB lights

NOTE: The data retrieved from the sensor are just raw values and cant be used for much. Audio signal processing is a very big and interesting topic to delve into. With good signal processing, you can detect even the frequencies and tones. In later tutorials I hope to take us much deeper.

Codes for project.

Related Articles

Integrate a keypad into your arduino project.

Systems that allow users to input their own data or in a way allow the users to control them by keypads or buttons are weirdly unique, yeah! They give the user some kind of feeling or control over the system. In this pretty simple and interesting piece, you will learn how to interface the 4×4 keypad matrix with your future arduino microcontroller projects that may need it.

Responses

Your email address will not be published. Required fields are marked *