Go Down

Topic: MSGEQ7 spectrum analyzer troubleshooting (Read 7444 times) previous topic - next topic

mathiasderidder

Oct 20, 2014, 09:12 pm Last Edit: Oct 23, 2014, 12:55 am by mathiasderidder
Hi there all,

I've been working on an LED spectrum analyzer for a while now. Because I'm new to all of this I started with just a microphone and some LEDs, KISS, no problem. Very soon I was curious if I could get the LEDs to react to high and low sounds recorded by the microphone. The MSGEQ7 was the perfect solution but I've been at it for a few days now and can't seem to figure out what I'm doing wrong. I've made a breadboard drawing using Fritzing to show you what I've got right now.

My code (found it on the www somewhere) is the following:

Code: [Select]

int analogPin = 0;
int strobePin = 2;
int resetPin = 3;
int spectrumValue[7];

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

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

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

  for (int i = 0; i < 7; i++)
  {
    digitalWrite(strobePin, LOW);
    delayMicroseconds(30);
    spectrumValue[i] = analogRead(analogPin);

    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();
}


The output in the serial monitor is just 0 0 0 0 0 0 0 all the time and sometimes steadily rises to 12 12 12 12 12 12 12 or a higher. I'm sure the microphone is still working and I'm also sure that the MSGEQ7 is working (I've bought 2 and both of them give the same results).

I've also searched the forum and found 2 similar cases (but no solutions) here (http://forum.arduino.cc/index.php?topic=96717.0), and here (http://forum.arduino.cc/index.php?topic=255869.0).

I know this is post number 1 but everyone has to start somewhere. I hope I'll be able to help other users out on this forum with their problems in the near future!

Kind regards, Mathias.

Grumpy_Mike

Well it looks like the power on the microphone is connected the wrong way round. You might have blown it up doing this.

dr_bigben

I am also a beginner when it comes to arduino. I was wondering if that sketch merely read the data coming off the msgeq7 chip or if it was trying to do something else too you just didn't have it hooked up in that picture.

mathiasderidder

#3
Oct 22, 2014, 02:02 pm Last Edit: Oct 22, 2014, 02:13 pm by mathiasderidder
First of all, thank you for your answer!

Well it looks like the power on the microphone is connected the wrong way round. You might have blown it up doing this.
Hi there Mike! I must have made a mistake while drawing the board. I'm actually using this microphone (http://www.adafruit.com/product/1713) and the GND would be on the correct place on that board.

I am also a beginner when it comes to arduino. I was wondering if that sketch merely read the data coming off the msgeq7 chip or if it was trying to do something else too you just didn't have it hooked up in that picture.
This sketch is only reading the data from the MSGEQ7 chip if I'm correct. It defines the pins I'm using and sets the pins in their required state (HIGH or LOW). The rest is just for printing out values and has a little built in noise filter.

Kind regards.

Grumpy_Mike

Quote
Hi there Mike! I must have made a mistake while drawing the board. I'm actually using this microphone (http://www.adafruit.com/product/1713) and the GND would be on the correct place on that board.
An answer can only be as good as the question, and if you do feed false information into the question we don't stand a chance of a correct answer do we?
So the question remains as to how you have wired it up, we still don't know as the module you have used has 5 connectors and your diagram only 3. So apart from the power how is the rest of it wired up?
Test the microphone by putting it into another analogue input say A1, and printing out the results. You should see a value of about 246 with no sound, and with sound it will be random about that value up or down about 200, so that is between 200 and 446 or there about. If you do not see this then your wiring or microphone are stuffed.

mathiasderidder

An answer can only be as good as the question, and if you do feed false information into the question we don't stand a chance of a correct answer do we?
So the question remains as to how you have wired it up, we still don't know as the module you have used has 5 connectors and your diagram only 3. So apart from the power how is the rest of it wired up?
Test the microphone by putting it into another analogue input say A1, and printing out the results. You should see a value of about 246 with no sound, and with sound it will be random about that value up or down about 200, so that is between 200 and 446 or there about. If you do not see this then your wiring or microphone are stuffed.
You're absolutely right Mike, I've updated the diagram in my first post. The microphone module with auto gain was not available in the Fritzing program, this is why I used the availably one with no auto gain and only 3 connectors (it is almost the same, I'm currently using the same 3 connectors, the other 2 are left untouched for now). I've tested the microphone as per your instructions and the output is indeed between 170 and 430 when I print the values so that part of the diagram definitely works (hooked it up to some LEDs as well and works like a charm).

Grumpy_Mike

Ok where did you get the schematic from for the chip? Those values look wrong on the caps. Can you post a photo of your wiring, not more than 1000 pixels wide.

mathiasderidder

Ok where did you get the schematic from for the chip? Those values look wrong on the caps. Can you post a photo of your wiring, not more than 1000 pixels wide.
Mike, thank you for bearing with me!

I've used the following tutorial to do the wiring and such (http://www.instructables.com/id/Blinking-LEDs-to-the-Frequency-of-Musi/). You can find the schematics over here (http://nuewire.com/info-archive/msgeq7-by-j-skoba/). There is a picture of my wiring in the attachments. Please note that the LED at the bottom is only there for further testing purposes.

Grumpy_Mike

Quote
I've used the following tutorial to do the wiring and such (http://www.instructables.com/id/Blinking-LEDs-to-the-Frequency-of-Musi/).
OK so you are new, the first rule of electronics is that instructables are crap - they are very poor and most of them do not work despite what the lying ba****ds giving feedback say. Never use anything on that site.

Just go with the schematic on that other link.

Now what is the thing on the right, it looks like an LED? This is why we need a schematic to see what you are actually doing rather than what you started from.

I can't see any audio input on pin 5, is it there?
It could be the angle but are you sure you are powering it from 5V and not the 3V3 next to it?
I also can't see the power going to pin 1 of the chip, it looks to be one out.

mathiasderidder

The LED is not connected to anything, I intended to get the MSGEQ7 chip up and running first. Everything is wired up according to the diagram from the first post (I've made that diagram myself based on my own wiring). No mistakes there I think... There is audio input on pin 5, it is powered from the 5V Arduino pin and there is power going to pin 1 of the MSGEQ7 chip. I'm starting to think I just have 2 faulty MSGEQ7 chips over here and a ton of bad luck. I've checked all the documentation and tutorials I can find on the internet, only to be sure that I got it right the first time. Even replaced all the components I was using to make sure they were not faulty. Still in love with Arduino though ;-) ...

Grumpy_Mike

Quote
There is audio input on pin 5, it is powered from the 5V Arduino pin
Do you mean that? The audio input should be from an iPad or some other audio source. The ground of the audio must be connected to the ground on the arduino and chip.

mathiasderidder

Quote
1. I can't see any audio input on pin 5, is it there?
2. It could be the angle but are you sure you are powering it from 5V and not the 3V3 next to it?
3. I also can't see the power going to pin 1 of the chip, it looks to be one out.
1. There is audio input on pin 5
2. It is powered from the 5V Arduino pin
3. There is power going to pin 1 of the MSGEQ7 chip

I should have been more clear about that.

elac

#12
Nov 09, 2014, 04:35 pm Last Edit: Nov 09, 2014, 05:04 pm by elac
Connect the mic out lead in series with a 0.01uF ceramic cap to MSGEQ7 pin 5.
Pin 8 needs a 33pF cap directly to ground.
*It's hard to tell from your pic whats what and where.
Try this sketch and see what the serial monitor reads.
Code: [Select]
   /* David Wang
     * Code that takes audio input from a 3.5mm cable
     * and flashes an LED strip based on the frequency
     * of the music.
     *
     * HUGE thanks to the arduino community
     * If you see your code here, I owe you my gratitude
     *
     */
     
    int analogPin = 0; // MSGEQ7 OUT
    int strobePin = 2; // MSGEQ7 STROBE
    int resetPin = 4; // MSGEQ7 RESET
    int spectrumValue[7];
     
    // MSGEQ7 OUT pin produces values around 50-80
    // when there is no input, so use this value to
    // filter out a lot of the chaff.
    int filterValue = 180;
     
    // LED pins connected to the PWM pins on the Arduino
     
    int ledPinR = 9;
    int ledPinG = 10;
    int ledPinB = 11;
     
    void setup()
    {
      //Serial.begin(9600);
      // Read from MSGEQ7 OUT
      pinMode(analogPin, INPUT);
      // Write to MSGEQ7 STROBE and RESET
      pinMode(strobePin, OUTPUT);
      pinMode(resetPin, OUTPUT);
     
      // Set analogPin's reference voltage
      analogReference(DEFAULT); // 5V
     
      // Set startup values for pins
      digitalWrite(resetPin, LOW);
      digitalWrite(strobePin, HIGH);
    }
     
    void loop()
    {
      // Set reset pin low to enable strobe
      digitalWrite(resetPin, HIGH);
      digitalWrite(resetPin, LOW);
     
      // Get all 7 spectrum values from the MSGEQ7
      for (int i = 0; i < 7; i++)
      {
        digitalWrite(strobePin, LOW);
        delayMicroseconds(30); // Allow output to settle
     
        spectrumValue[i] = analogRead(analogPin);
     
        // Constrain any value above 1023 or below filterValue
        spectrumValue[i] = constrain(spectrumValue[i], filterValue, 1023);
     
     
        // Remap the value to a number between 0 and 255 if needed
       // spectrumValue[i] = map(spectrumValue[i], filterValue, 1023, 0, 255);
     
        Serial.print(spectrumValue[i]);
        Serial.print(" ");
        digitalWrite(strobePin, HIGH);
       }
     
       Serial.println();
     }

Modified from the Instructables sketch.
It's all about the skills

nubsauce2025

I've recently been messing around with the MSGEQ7 chip and set it up in the same way as many of these other posts. I have had the issue that the serial port is outputting the same value for each frequency. Attached is a picture of the serial port. The only major difference I have noticed is that my audio in is from a stripped audio cord. The cord has a red, white, and black wires. I assumed that the red and white correspond to the audio in and the black is the ground wire. Anyone have any ideas of what I could change or what might be wrong?

ericajfitz

I am having this same issue. I had it running on the breadboard after quite a bit of fiddling around and redoing the breadboard. Once I soldered this problem started and now that I've moved back to the breadboard it only works when I physically touch one end of the 33pf capacitor. Quite confused :(

Go Up