Listen for specific frequency I’m trying to build a custom baby monitor for my wife who is deaf. It needs to detect loud noises and listen for a specific series of tones from a feeding pump our daughter uses.  It will then send a radio signal to the other room to trigger a bed shaker. 

I do have a loop which samples the MAX4466 microphone and uses a “peakToPeak” calculation to determine volume, which I can use to trigger for loud noises (pasted below).  However, I cannot figure out how to determine the frequency of a noise sample.  I’ve tried searching for other sketches and tutorials that would work, but haven’t found anything.  The feeding pump, when it has an error puts out a series of tones which alternates between 4.1&nbsp;kHz and 2.1&nbsp;kHz.   What I wanted to do is see if the first tone is sounding, and then if the second tone shows up within a couple seconds afterwards, then it would trigger sending the signal to the other device. 

I’ve tried for two days now to find a way to determine the frequency, but haven’t figured it out.  Any help would be greatly appreciated.  The closest I was able to get was this: Instructables - Arduino Frequency Detection, but when I use this script, the Arduino can no longer do analogRead() to get the status of various setting knobs and such I have on the device.  

The script I use to get the sound level / loudness is: 

  #define micPin 0                      // Microphone
  const int sampleWindow = 96;          // Sample window width in mS (50 mS = 20Hz)
  unsigned int sample;
    while (millis() - startMillis &lt; sampleWindow) {
      sample = analogRead(micPin);
      // Check peakToPeak mins and maxs
        if (sample &lt; 1024) {
          // toss out spurious readings     
           if (sample &gt; signalMax) { signalMax = sample; }          // save just the max levels
           else if (sample &lt; signalMin) { signalMin = sample; }     // save just the min levels
        }
    }
    peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
As stated in previous answers, frequency measurement is unlikely to be
reliable because the microphone is going to pick up ambient noise, which
is a combination of many individual frequencies. You want instead to see
how much sound amplitude you have at the specific frequency of the
feeding pump. Fourier analysis seems like the natural tool for the job.

However, a Fourier transform is heavy math, and overkill for your
application. You are only interested in the Fourier amplitude at one
specific frequency. Computing that single amplitude is way easier and
faster than doing a full-fledged Fourier transform.

My preferred method for doing that is called homodyne detection. It
is fast enough to be done in real time by an Arduino Uno sampling at
9.6&nbsp;kHz. Basically you multiply the input signal by both a sine and
a cosine at the target frequency, then you low-pass filter both
products. The two resulting signals are the real and the imaginary part
of the complex amplitude you are looking for.

Here is a small program of mine that does almost exactly what you are
looking for: homodyne.ino. It is set for one specific frequency
(1&nbsp;kHz, but it's trivial to change), and you will have to adapt it
to be able to change the target frequency between 4.1 and 2.1&nbsp;kHz.