Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Sound Sensor

Sound Sensor

Scheduled Pinned Locked Moved My Project
31 Posts 7 Posters 24.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • YveauxY Yveaux

    @epierre I have very little time, but sharing the sketch might help to make your problem clear...

    epierreE Offline
    epierreE Offline
    epierre
    Hero Member
    wrote on last edited by
    #15

    @Yveaux thanks, here it is:

    avr_splmeter_02b.zip

    http://davidegironi.blogspot.fr/2014/02/a-simple-sound-pressure-level-meter-spl.html

    z-wave - Vera -> Domoticz
    rfx - Domoticz <- MyDomoAtHome <- Imperihome
    mysensors -> mysensors-gw -> Domoticz

    YveauxY 1 Reply Last reply
    0
    • epierreE epierre

      @Yveaux thanks, here it is:

      avr_splmeter_02b.zip

      http://davidegironi.blogspot.fr/2014/02/a-simple-sound-pressure-level-meter-spl.html

      YveauxY Offline
      YveauxY Offline
      Yveaux
      Mod
      wrote on last edited by
      #16

      @epierre Had a quick look at the code. Seems the TIMSK stuff is just for timing the ADC samples at regular interval; the TIMER1_OVF_vect sets a flag (audioget_takesample) which is scanned for in the audioget_getsamples() function.
      Exactly the same behavior you can get by waiting using delay() or delayMicroseconds(), and then get the sample.
      That's probably easier then getting the raw timer stuff going.

      http://yveaux.blogspot.nl

      1 Reply Last reply
      0
      • epierreE Offline
        epierreE Offline
        epierre
        Hero Member
        wrote on last edited by
        #17

        Since @hek is interrested, I'm revivind this post with several microphone available out there, in fact impossible to know if these use real electet ones...

        IMG_20150801_185937.jpg

        @BulldogLowell I've seen you've participated here http://forum.arduino.cc/index.php?topic=208520.15 but do you think this was the good solution ? if you go through http://davidegironi.blogspot.fr/2014/02/a-simple-sound-pressure-level-meter-spl.html the questions is open...

        z-wave - Vera -> Domoticz
        rfx - Domoticz <- MyDomoAtHome <- Imperihome
        mysensors -> mysensors-gw -> Domoticz

        Moshe LivneM 2 Replies Last reply
        0
        • hekH Offline
          hekH Offline
          hek
          Admin
          wrote on last edited by hek
          #18

          Hmm.. not super easy to calculate an actual sound "pollution" value or do dB calculations using this I guess.

          Hmm.. Adafruit using a sample window in their example.

          https://learn.adafruit.com/adafruit-microphone-amplifier-breakout/measuring-sound-levels

          1 Reply Last reply
          0
          • hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by
            #19

            How does this differ from yours @epierre ?

            http://www.ebay.com/itm/Sound-Detection-Sensor-Module-Voice-Sensor-Intelligent-Vehicle-LM386-Audio-Power-/261598751181?pt=LH_DefaultDomain_0&hash=item3ce88029cd

            Seems to be two chips on it..

            1 Reply Last reply
            0
            • epierreE epierre

              Since @hek is interrested, I'm revivind this post with several microphone available out there, in fact impossible to know if these use real electet ones...

              IMG_20150801_185937.jpg

              @BulldogLowell I've seen you've participated here http://forum.arduino.cc/index.php?topic=208520.15 but do you think this was the good solution ? if you go through http://davidegironi.blogspot.fr/2014/02/a-simple-sound-pressure-level-meter-spl.html the questions is open...

              Moshe LivneM Offline
              Moshe LivneM Offline
              Moshe Livne
              Hero Member
              wrote on last edited by
              #20

              @epierre I have ordered almost any kind of sound sensor on aliexpress for my washing machine sensor (at first I thought to get the beeps). They were all really bad.... I went the vibration way, but if I had to start all over again I think I would get https://www.sparkfun.com/products/9964

              1 Reply Last reply
              0
              • epierreE epierre

                Since @hek is interrested, I'm revivind this post with several microphone available out there, in fact impossible to know if these use real electet ones...

                IMG_20150801_185937.jpg

                @BulldogLowell I've seen you've participated here http://forum.arduino.cc/index.php?topic=208520.15 but do you think this was the good solution ? if you go through http://davidegironi.blogspot.fr/2014/02/a-simple-sound-pressure-level-meter-spl.html the questions is open...

                Moshe LivneM Offline
                Moshe LivneM Offline
                Moshe Livne
                Hero Member
                wrote on last edited by
                #21

                @epierre Osrry, forgot to mention that the killer was the lack of amplification on the cheap modules. The diff between silence and hand clap few cm from the mic was only a few numbers on the reading. When you have amplification it stretch it across the 1023 range, I think.

                1 Reply Last reply
                0
                • epierreE Offline
                  epierreE Offline
                  epierre
                  Hero Member
                  wrote on last edited by epierre
                  #22

                  The electret schema is here :
                  http://www.edutek.ltd.uk/CBricks_Pages/Electret_Microphone.html

                  and IMHO the best we could use is this one:
                  https://www.adafruit.com/products/1063

                  This fully assembled and tested board comes with a 20-20KHz electret microphone soldered on. For the amplification, we use the Maxim MAX4466, an op-amp specifically designed for this delicate task! The amplifier has excellent power supply noise rejection, so this amplifier sounds really good and isn't nearly as noisy or scratchy as other mic amp breakouts we've tried!
                  
                  This breakout is best used for projects such as voice changers, audio recording/sampling, and audio-reactive projects that use FFT. On the back, we include a small trimmer pot to adjust the gain. You can set the gain from 25x to 125x. That's down to be about 200mVpp (for normal speaking volume about 6" away) which is good for attaching to something that expects 'line level' input without clipping, or up to about 1Vpp, ideal for reading from a microcontroller ADC. The output is rail-to-rail so if the sounds gets loud, the output can go up to 5Vpp!
                  

                  Why do we need an FFT afterward ?

                  Using the normal Arduino analogRead() function would be much too slow for sampling audio. Instead, a feature of the microcontroller’s analog-to-digital converter called free-run mode is utilized. This automatically takes repeated analog samples at precise intervals…about 9.6 KHz for this project, the maximum a 16 MHz Arduino can handle with 10-bit samples.
                  
                  The raw audio samples are converted into a frequency spectrum using a fast Fourier transform or FFT. There are a number of Arduino FFT libraries out there, but we keep finding ourselves returning to the venerable ELM-ChaN ffft library for its speed and good looks.
                  
                  The FFT output still needs a bit of massaging to make for a good presentation on the limited 8x8 matrix. Several tables of scales and weights de-emphasize certain frequency ranges as they’re reduced to just eight columns. The software works at keeping the graph interesting, but some columns will always be less lively than others, especially comparing live speech against music of varying genres. If everything seems to stick toward one end of the graph, try another musician, musical genre, or different speakers.
                  
                   Finally, because ADC registers are accessed directly, specific interrupts are used, and the FFT code is in AVR assembly language, this software will not run on upscale boards like the Arduino Due, ChipKIT or Teensy 3.0. It is strictly for “classic” Arduinos.
                  

                  led_matrix_proto.jpg

                  https://github.com/adafruit/piccolo

                  z-wave - Vera -> Domoticz
                  rfx - Domoticz <- MyDomoAtHome <- Imperihome
                  mysensors -> mysensors-gw -> Domoticz

                  YveauxY 1 Reply Last reply
                  0
                  • epierreE epierre

                    The electret schema is here :
                    http://www.edutek.ltd.uk/CBricks_Pages/Electret_Microphone.html

                    and IMHO the best we could use is this one:
                    https://www.adafruit.com/products/1063

                    This fully assembled and tested board comes with a 20-20KHz electret microphone soldered on. For the amplification, we use the Maxim MAX4466, an op-amp specifically designed for this delicate task! The amplifier has excellent power supply noise rejection, so this amplifier sounds really good and isn't nearly as noisy or scratchy as other mic amp breakouts we've tried!
                    
                    This breakout is best used for projects such as voice changers, audio recording/sampling, and audio-reactive projects that use FFT. On the back, we include a small trimmer pot to adjust the gain. You can set the gain from 25x to 125x. That's down to be about 200mVpp (for normal speaking volume about 6" away) which is good for attaching to something that expects 'line level' input without clipping, or up to about 1Vpp, ideal for reading from a microcontroller ADC. The output is rail-to-rail so if the sounds gets loud, the output can go up to 5Vpp!
                    

                    Why do we need an FFT afterward ?

                    Using the normal Arduino analogRead() function would be much too slow for sampling audio. Instead, a feature of the microcontroller’s analog-to-digital converter called free-run mode is utilized. This automatically takes repeated analog samples at precise intervals…about 9.6 KHz for this project, the maximum a 16 MHz Arduino can handle with 10-bit samples.
                    
                    The raw audio samples are converted into a frequency spectrum using a fast Fourier transform or FFT. There are a number of Arduino FFT libraries out there, but we keep finding ourselves returning to the venerable ELM-ChaN ffft library for its speed and good looks.
                    
                    The FFT output still needs a bit of massaging to make for a good presentation on the limited 8x8 matrix. Several tables of scales and weights de-emphasize certain frequency ranges as they’re reduced to just eight columns. The software works at keeping the graph interesting, but some columns will always be less lively than others, especially comparing live speech against music of varying genres. If everything seems to stick toward one end of the graph, try another musician, musical genre, or different speakers.
                    
                     Finally, because ADC registers are accessed directly, specific interrupts are used, and the FFT code is in AVR assembly language, this software will not run on upscale boards like the Arduino Due, ChipKIT or Teensy 3.0. It is strictly for “classic” Arduinos.
                    

                    led_matrix_proto.jpg

                    https://github.com/adafruit/piccolo

                    YveauxY Offline
                    YveauxY Offline
                    Yveaux
                    Mod
                    wrote on last edited by
                    #23

                    @epierre said:

                    Why do we need an FFT afterward ?

                    We don't 'need' an fft, it simply depends on your application.
                    An fft breaks down your audio signal into the different frequency components it is composed of.
                    This can be used to display a frequency-intensity chart, as shown on the pixel display in your picture.
                    Low frequency (bass) is usually shown on the left, high frequency (treble) on the right.

                    http://yveaux.blogspot.nl

                    1 Reply Last reply
                    0
                    • epierreE Offline
                      epierreE Offline
                      epierre
                      Hero Member
                      wrote on last edited by
                      #24

                      @yveaux very nice to see you again !

                      Although I just want to get a dB mesure out, Davide Gironi described a more complex process:

                      sound level meter or sound meter is an instrument which measures sound pressure level. Sound pressure level (SPL) or sound level is a logarithmic measure of the effective sound pressure of a sound relative to a reference value. It is measured in decibels (dB) above a standard reference level. The commonly used reference sound pressure in air is = 20 µPa (rms) which is usually considered the threshold of human hearing. Keep in mind that 1 pascal will equal an SPL of 94 dB. Because the frequency response of human hearing changes with amplitude, a weighting have been established for measuring sound pressure. Usually the A-weighting curve is used. A weighting curve is a graph of gain across the frequency range (10Hz to 20kHz).
                      
                      To compute SPL measurements, the meters loop is:
                      
                      1- collects N samples
                      2- do FFT for the N samples collected, the signal is now transformed in the frequency domain
                      3 - apply A-weighting (in freq domain)
                      4 - get magnitude of the signal
                      5- get RMS value of the signal
                      6 - apply a time-weight filter to RMS value
                      7 - compute the SPL using the RMS value
                      8 - output data
                      

                      z-wave - Vera -> Domoticz
                      rfx - Domoticz <- MyDomoAtHome <- Imperihome
                      mysensors -> mysensors-gw -> Domoticz

                      YveauxY 1 Reply Last reply
                      0
                      • epierreE epierre

                        @yveaux very nice to see you again !

                        Although I just want to get a dB mesure out, Davide Gironi described a more complex process:

                        sound level meter or sound meter is an instrument which measures sound pressure level. Sound pressure level (SPL) or sound level is a logarithmic measure of the effective sound pressure of a sound relative to a reference value. It is measured in decibels (dB) above a standard reference level. The commonly used reference sound pressure in air is = 20 µPa (rms) which is usually considered the threshold of human hearing. Keep in mind that 1 pascal will equal an SPL of 94 dB. Because the frequency response of human hearing changes with amplitude, a weighting have been established for measuring sound pressure. Usually the A-weighting curve is used. A weighting curve is a graph of gain across the frequency range (10Hz to 20kHz).
                        
                        To compute SPL measurements, the meters loop is:
                        
                        1- collects N samples
                        2- do FFT for the N samples collected, the signal is now transformed in the frequency domain
                        3 - apply A-weighting (in freq domain)
                        4 - get magnitude of the signal
                        5- get RMS value of the signal
                        6 - apply a time-weight filter to RMS value
                        7 - compute the SPL using the RMS value
                        8 - output data
                        
                        YveauxY Offline
                        YveauxY Offline
                        Yveaux
                        Mod
                        wrote on last edited by
                        #25

                        @epierre Don't overdo it.
                        I'd expect mapping the analog output of the sensor to dB will work quite well too.
                        You need to calibrate the output once and the resulting calibration table can be used to map sensor output to dB later on.

                        http://yveaux.blogspot.nl

                        1 Reply Last reply
                        0
                        • epierreE Offline
                          epierreE Offline
                          epierre
                          Hero Member
                          wrote on last edited by
                          #26

                          @Yveaux for calibration we have some software in the smartphone, at least they would be equal of course ;-)

                          z-wave - Vera -> Domoticz
                          rfx - Domoticz <- MyDomoAtHome <- Imperihome
                          mysensors -> mysensors-gw -> Domoticz

                          YveauxY 1 Reply Last reply
                          0
                          • epierreE epierre

                            @Yveaux for calibration we have some software in the smartphone, at least they would be equal of course ;-)

                            YveauxY Offline
                            YveauxY Offline
                            Yveaux
                            Mod
                            wrote on last edited by
                            #27

                            @epierre said:

                            software in the smartphone

                            That will be equally inaccurate I suppose...

                            http://yveaux.blogspot.nl

                            1 Reply Last reply
                            0
                            • epierreE Offline
                              epierreE Offline
                              epierre
                              Hero Member
                              wrote on last edited by
                              #28

                              @Yveaux best that nothing to start with !

                              z-wave - Vera -> Domoticz
                              rfx - Domoticz <- MyDomoAtHome <- Imperihome
                              mysensors -> mysensors-gw -> Domoticz

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                gigaguy
                                wrote on last edited by
                                #29

                                Did anyone get this working? I have the 1st mic in epierre's picture above. I am getting values from it. I am currently using the analog pin, based on the posts here. The values dont seem accurate. They dont change with sound level. I am just trying to get a noise % level.

                                1 Reply Last reply
                                0
                                • epierreE Offline
                                  epierreE Offline
                                  epierre
                                  Hero Member
                                  wrote on last edited by
                                  #30

                                  Hello,

                                  First my sketch is not good enough, I don't know why it keeps increasing the value reported...

                                  Second, I do have results just from the raw adc with these, check the wiring again. Also be reminded some sensors above with only 3 pins may have only a digital output (may so you have to check before buying). In case it is digital, the resistor knob will serve to say above which level it wil send the HIGH signal.

                                  z-wave - Vera -> Domoticz
                                  rfx - Domoticz <- MyDomoAtHome <- Imperihome
                                  mysensors -> mysensors-gw -> Domoticz

                                  G 1 Reply Last reply
                                  0
                                  • epierreE epierre

                                    Hello,

                                    First my sketch is not good enough, I don't know why it keeps increasing the value reported...

                                    Second, I do have results just from the raw adc with these, check the wiring again. Also be reminded some sensors above with only 3 pins may have only a digital output (may so you have to check before buying). In case it is digital, the resistor knob will serve to say above which level it wil send the HIGH signal.

                                    G Offline
                                    G Offline
                                    gigaguy
                                    wrote on last edited by
                                    #31

                                    @epierre thanks. I do have 4 pins, and im using the analog one. I noticed the increasing value you mentioned. I tried to get raw and got a value, but when taking into the mic, the value doesn't appear to change. Does yours?

                                    1 Reply Last reply
                                    0
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    23

                                    Online

                                    11.7k

                                    Users

                                    11.2k

                                    Topics

                                    113.1k

                                    Posts


                                    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                    • Login

                                    • Don't have an account? Register

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • MySensors
                                    • OpenHardware.io
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular