↑ Return to Info Archive

MSGEQ7 by J Skoba

This is an archive of an article written by J Skoba that was originally published here: http://skoba.no-ip.org/msgeq7/

Connecting an MSGEQ7 to an Arduino

The MSGEQ7 by Mixed-Signal Integration is a Seven Band Graphic Equalizer Display Filter IC. What a mouthful! Long story short, it splits an audio signal into the dc equivalent of its amplitude at 7 set frequencies. It was provided to me by Nate Seldie and Pete Dokter over at SparkFun electronics. Thanks guys!

A longer description of the chip from the manufacturer’s website, for those interested:

The seven band graphic equalizer IC is a CMOS chip that divides the audio spectrum into seven bands. 63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz and 16kHz. The seven frequencies are peak detected and multiplexed to the output to provide a DC representation of the amplitude of each band. No external components are needed to select the filter responses. Only an off chip resistor and capacitor are needed to select the on chip clock oscillator frequency. The filter center frequencies track this frequency.

Other than coupling and decoupling capacitors, no other external components are needed. The chip supply can be between 2.7 and 5.5 volts with 5 volts providing the best performance. The device has very low quiescent current (less than 1ma typical) for portable audio devices. the multiplexor is controlled by a reset and a strobe, permitting multiplexor readout with only two pins. The multiplexor readout rate also controls the decay time (10% decay per read), so no external pins are needed for this function.

Breadboard Stuff

The MSGEQ7 is awesomely simple to hook up – it requires two digital pins, an analog pin, and a couple spare parts you should have lying around. This is the schematic I am using (click any of the pictures below for a bigger version):

Ive shown the direction of the signals, as well as put the pin connection in (brackets) above or below the name of the pin. To reiterate, Strobe is connected to Digital 2, Reset is connected to Digital 3, and the DC Output Pin is connected to Analog 0.

Here’s the circuit built and connected to my Arduino:

And here’s an artsy shot from the side:

Code and a quick demo

The code is very simple; you reset the chip, and then strobe the chip 7 times. Each strobe puts a new DC value onto the output (corresponding to a specific frequency), which is read into an array. Ive got some Serial code printing the results, and its kind of neat to see. Here is the code Ive written; feel free to use it in whichever way youd like. If Ive got something wrong (it seems to work, but you never know), Id love for you to let me know. Anywho, here it is:

int analogPin = 0; // read from multiplexer using analog input 0
int strobePin = 2; // strobe is attached to digital pin 2
int resetPin = 3; // reset is attached to digital pin 3
int spectrumValue[7]; // to hold a2d values

void setup()
{
 Serial.begin(9600);
 pinMode(analogPin, INPUT);
 pinMode(strobePin, OUTPUT);
 pinMode(resetPin, OUTPUT);
 analogReference(DEFAULT);

 digitalWrite(resetPin, LOW);
 digitalWrite(strobePin, HIGH);

 Serial.println("MSGEQ7 test by J Skoba");
}

void loop()
{
 digitalWrite(resetPin, HIGH);
 digitalWrite(resetPin, LOW);

 for (int i = 0; i < 7; i++)
 {
 digitalWrite(strobePin, LOW);
 delayMicroseconds(30); // to allow the output to settle
 spectrumValue[i] = analogRead(analogPin);

 // comment out/remove the serial stuff to go faster
 // - its just here for show
 if (spectrumValue[i] < 10)
 {
 Serial.print(" ");
 Serial.print(spectrumValue[i]);
 }
 else if (spectrumValue[i] < 100 )
 {
 Serial.print(" ");
 Serial.print(spectrumValue[i]);
 }
 else
 {
 Serial.print(" ");
 Serial.print(spectrumValue[i]);
 }

 digitalWrite(strobePin, HIGH);
 }
 Serial.println();
}

When the Serial readout is turned on, you get a bunch of numbers. What do they mean? Well, each column relates to a specific frequency that the chip looks for (63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz, and 16kHz), and the number (which ranges from 0-1023) corrolates to how “loud” the sound at each frequency is. I say “loud” because Im not exactly sure how the chip does the conversion from loudness (in dB) to a 0-1023 integer. If you look at the following picture, youll see a screenshot of the code running. The program on the left is a frequency generator, which I will use to demo the code at a couple different frequencies. In this first shot, the generator is off – the ~60 value you see is my sound card making no sound. Neat! (Again, click on each picture for a larger version) The rest show different frequencies. Enjoy!

63Hz:

400Hz:

2.5kHz:

16kHz:

12 comments

2 pings

Skip to comment form

  1. oddalot

    This is an AWESOME tutorial! Thanks for the help, it will really make my project go a lot smoother.

  2. El Artista

    I’ve being working in a project with this chip. Thanks for sharing your.

  3. Austin

    Hello I have a question regarding you schematic. Is there a reason you did it different then what the datasheet said. Im asking because I want to purchase this chip and I am not sure what caps I should buy since the circuits use different ones.

    1. willnue

      Austin,
      The capacitors in the schematic are the same as the datasheet, but the scale is different on the schematic. For example 100 Nanofarads (100nF) = .1 Microfarad (0.1uF). If you are looking to buy them use the Microfarad values in the datasheet.

  4. Ryan Gibson

    Hey,

    Great blog and an awesome build here. Do you have an email I can potentially contact you on? I have a few questions to ask.

    Thanks

    Ryan

  5. shawn

    When I turn on my circuit and apply music (or in this case, a 440hz tone, I get this output on the arduino serial monitor:

    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    927 931 931 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    927 929 932 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    924 927 927 0 0 0 0

    The data roughly stays the same no matter what.

    http://www.pasteall.org/pic/21243 <– Picture of my circuit ( the two resistors on the top left corner of the image have been changed out for 1 220k resistor)

    http://www.pasteall.org/pic/21245 <– Picture of how I wired it up

    I verified that there is power to the IC.

    What am I doing wrong?

  6. Zyrusthc

    Have Create a Fritzing from this Howto whis Equalizer Output on Display
    http://fritzing.org/projects/msgeq7-audio-equalizer/

    1. willnue

      Zyrusthc,
      Saw your Fritzing links on arduino.cc – Nice work. Also like the one you created for using the Sparkfun Spectrum Shield at http://fritzing.org/projects/sparkfun-spectrum-shield-audio-equalizer-lcd/
      Keep up the good work!

  7. lemuroid

    Thank you.
    Built the circuit and it worked first time out of the box.
    you rule.

  8. BigMitch

    Thank you!!!

  9. Joey2point0

    THANK YOU!!! EXCELLENT

  10. willnue

    You can buy them from all the big suppliers, but the best thing to do is pick up a capacitor assortment – if you don’t need the other values now you probably will later… Here are some I like:

    Futurelec (Ships from Thailand)
    Ceramic Capacitor pack
    http://www.futurlec.com/ValuePacks.shtml

    Electronix Express (Ships from USA)
    http://www.elexp.com/cmp_drkt.htm

  1. Christmasqualizer is the next light switch rave « LED Lighting – LEDs, Home LEDs, LED Strips

    [...] are off-the-shelf Christmas lights. A simple circuit for the 7-band equalizer was built following this article. The build uses an MSGEQ7 equalizer chip takes audio from any source. The volume level of the seven [...]

  2. Working with the MSGEQ7 clock input | Q&A System

    [...] just got a MSGEQ7 equalizer chip. I have everything wired up like http://nuewire.com/info-archive/msgeq7-by-j-skoba/ except for the 33pF cap. I have no idea where to even find those. I think somehow the cap and [...]

Leave a Reply

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


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>