Go Down

Topic: MSGEQ7 problem [SOLVED] (Read 87 times) previous topic - next topic

jejpi23

Aug 01, 2020, 03:31 pm Last Edit: Aug 01, 2020, 05:58 pm by jejpi23
Hello,

I have recently tried to create an Audio Visualizer with MSGEQ7. First i tried to understand how the chip works in order to put it in my project. I connected the chip as they say in datasheet [first attachment] , but the readings are always the same and equal to 800 +- 10. I tried other connections from projects in this site, however the results are always the same. I checked the connections and the audio output they seemed to work as they should. Can anyone help me with this, because i don't have any idea what is wrong with it.

The code
/*
  Test Sketch for the MSGEQ7
  from Mixed Signal Integration

  the IOs in this Sketch are
  compatible with the Shield
  from Sparkfun:

  http://www.sparkfun.com/products/10306

  Author: Simon Waldherr
  License: MIT
*/

int AnalogIn = 0;    // read from multiplexer using analog input 0
int NextBand = 2;    // strobe (next band) is attached to digital pin 4
int ResetPin = 3;    // reset is attached to digital pin 5
int Spectrum[7];     // array to store analog values
int filter = 80;  // *** added min level above noise

void setup()
  {

    // init IO
//   delay(250);  // *** not necessary
//   pinMode(AnalogIn, INPUT);  // *** not necessary
    pinMode(NextBand, OUTPUT);
    pinMode(ResetPin, OUTPUT);
    analogReference(DEFAULT);
    digitalWrite(ResetPin, HIGH);
    digitalWrite(ResetPin, LOW);  // *** added
//    digitalWrite(NextBand, HIGH);  //*** removed

    // init Serial
//   delay(250);  // *** not necessary
    Serial.begin(9600);  //*** chg'd from 115200 to 9600
                         //*** make sure Monitor is 9600
    Serial.println("|______________________________|");
    Serial.println("|            MSGEQ7            |");
    Serial.println("|------------------------------|");
    Serial.println("| Seven Band Graphic Equalizer |");
    Serial.println("|------------------------------|");
    Serial.println("|     on an Arduino Shield     |");
    Serial.println("|------------------------------|");
    Serial.println("|      with Serial output      |");
    Serial.println("|------------------------------|");
    // wait
    delay(5000);
  }

void loop()
  {
// *** Reset here works but slighly better response without it
//    digitalWrite(ResetPin, HIGH);                          // reset band to 63 Hz
//    digitalWrite(ResetPin, LOW);

    for (int i = 0; i < 7; i++)                            // for loop to save values to array
      {
        // HIGH to LOW transition works best here
        digitalWrite(NextBand, HIGH);  //*** added
        digitalWrite(NextBand, LOW);
        delayMicroseconds(22);                               // to allow the output to settle
//        Spectrum = doMath(analogRead(AnalogIn));        // read actual value to array
        // read spectrum level and filter noise
        Spectrum = constrain(analogRead(AnalogIn), filter, 1023);  //*** added
//        digitalWrite(NextBand, HIGH);  //*** moved up      // select next band (160Hz, 400Hz, 1000Hz, 2500Hz, 6250Hz, 16kHz)
        delayMicroseconds(3);  //*** probably not necessary
      }

    for (int i = 0; i < 7; i++)                            // for loop to print array to Serial
      {
        if (Spectrum == filter )  //***  chg'd               // ignore values lower than 100 (you also can use doMath())
           {
            Serial.print("\t");
            Serial.print("0");
          }
        else
          {
            Serial.print("\t");
            Serial.print(Spectrum);
          }
      }
    Serial.println();                                      // Serial new line
    //delay(500);                                          // this sketch prints really much data, you can slow down if you have to.
  }

slipstick

#1
Aug 01, 2020, 05:44 pm Last Edit: Aug 01, 2020, 05:46 pm by slipstick
Spectrum is an array. So trying to print it or apply a constrain to it is never going to work. That code doesn't even compile so I don't believe it prints any values at all.

OTOH your main problem may be that you have a fake MSGEQ7 because there seem to be a lot of them about. Where did you get yours from?

Steve'

jejpi23

I bought them on Ebay from Chinese supplier so they are probably fakes you say. Thank you for the information.

Go Up