Go Down

Topic: Measuring values from microphone sensor using Arduino Uno (Read 361 times) previous topic - next topic

YiHong

Hi, I am trying to get value readings from a Velleman microphone sensor using an Arduino Uno. From what I understand is that by using analogRead, I will get the peak value from the sensor. I have played a single tone to the sensor and connected it to an oscilloscope. I got perfect sine wave but why am I getting random values from the serial monitor?  :smiley-confuse:

groundFungus

#1
Mar 15, 2019, 03:00 pm Last Edit: Mar 15, 2019, 03:03 pm by groundFungus
Quote
From what I understand is that by using analogRead, I will get the peak value from the sensor.
What leads you to believe that?  Can you provide a link to where you saw that?  

The analog output does not give the peak amplitude, just the instantaneous amplitude.  To get a peak amplitude take many samples and look for the peak with software.  You get ransom looking data because you are sampling the wave at different points on the wave.  If you sample at exactly the frequency of the wave you will get a steady reading, but the reading could be any point on the wave.  See aliasing.

The digital signal changes state based on a threshold that you  set with the pot (not peak either).

YiHong

Hi, thank you for your reply. Do you know how can I get a constant value then?

groundFungus



groundFungus

Google "arduino input peak detector" for information on how to do it in software and hardware. 

freaklabs

Hi. You will be sampling the incoming signal so you have to determine the sampling rate you will be using. For AnalogRead, the sampling rate is defaulted to approximately 10 ksps. Theoretically you can sample up to 5 kHz signals with that. For the peak detector, you'll need to write that in software yourself, and if your algorithm takes too long, you won't be able to sample at the maximum rate. Also, you should make sure the microphone output comes from an opamp. If its a direct output from a mic, then you will need to interface it to an opamp, set the gain, and add a low pass filter to cut off anything above 5kHz. That is called signal conditioning and is needed to provide a strong, quality signal to the ADC in the frequency band of interest.
Hope that helps.
FreakLabs
Wireless Technology for the environment, wildlife, and agriculture
https://freaklabs.org
https://hackerfarm.jp
Twitter: @freaklabs

Go Up