no values from msgeq7

This is starting to give me headaches, I really have no idea what I am doing wrong.
Let me explain.
I have connected the msgeq7 correctly
.
The capacitors and resistors have the correct values.

But I am still getting no values.
This is my output:
18 17 17 17 18 18 18
18 18 18 17 18 18 18

When I disconnect pin A0, this is my output
199 200 200 200 200 200 200
195 195 195 195 195 194 194
203 203 203 203 203 203 203

this is the code I am using:

int AnalogIn = 0;    
int NextBand = 4;   
int ResetPin = 5;    
int Spectrum[7];    


void setup()
  {

    pinMode(AnalogIn, INPUT);
    pinMode(NextBand, OUTPUT);
    pinMode(ResetPin, OUTPUT);
    analogReference(DEFAULT);
    digitalWrite(ResetPin, LOW);
    digitalWrite(NextBand, HIGH);

   
    Serial.begin(9600);
   
  }

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

    for (int i = 0; i < 7; i++)                            
      {
        digitalWrite(NextBand, LOW);
        delayMicroseconds(22);                            
        Spectrum[i] = analogRead(AnalogIn);        
        digitalWrite(NextBand, HIGH);                     
        
      }

    for (int i = 0; i < 7; i++)                            // for loop to print array to Serial
      {
        if (Spectrum[i] < 10 )                            
          {
            Serial.print("\t");
            Serial.print("0");
          }
        else
          {
            Serial.print("\t");
            Serial.print(Spectrum[i]);
          }
      }
    Serial.println();                                     
    delay(500);                                         
  }

I am using an audiocable from my laptop to an audiojack which is connected to ground an pin5 (it doesn't matter if this is connected or not, it keeps on giving the same values)

I hope somebody can help me

Peter

The diagram seems to show the IC's Strobe pin, IC pin 4, connected to Arduino pin 2, and the IC's Reset pin, IC pin 7, connected to Arduino pin 4. The code seems to expect to find Strobe connected to pin 4, and Reset connected to Pin 5. That seems wrong.

I tried so many different codes, that I had posted the wrong one.
The pins are connected correctly, pin4 (strobe) is connected to correct Arduino pin and the reset pin too.
I just mixed up the wrong code with the correct screenshot :slight_smile:

My excuses for the miusunderstanding

....I've never used the MSGEQ7.

Did you develop that sketch yourself, or did you find the example code somewhere?

The datasheed says this:

Each read decays that channel approximately 10%.

That tells me there is smoothing/filtering and the readings need to "settle-in". So, the 1st readings may not be right and the problem might be related to the fact that you are interrupting the timing for the serial print and delay.

Just as an experiment, try running 100 loops (or maybe more) and then print the last set of readings. (i.e. Put your analog-read for-loop inside another loop.)

Using sparkfun's datasheet, here - https://www.sparkfun.com/datasheets/Components/General/MSGEQ7.pdf. The last page shows several timing requirements. I don't see that the sketch accommodates them.

Here's one: trs - Reset to Strobe Delay 72 uS min - time from falling edge of Reset to falling edge of Strobe. I don't see the sketch waiting any time at all between dropping Reset and dropping Strobe.

Here's another: to - Output Settling Time 36 uS min - time it takes the output to stabilize after falling edge of Strobe. I'd expect that values measured before that time elapses to be unreliable. I see the sketch waiting 22 uS, but that's not long enough.

So, I'd suggest reviewing the IC's timing requirements, and adding delays to accommodate them.

Many thanks for the suggestions and tips, but I still have no values reading it.

I've changed the code into:

digitalWrite(ResetPin, HIGH); 
delayMicroseconds(72);  ;  
    digitalWrite(ResetPin, LOW);

    for (int i = 0; i < 7; i++)                            
      {
        digitalWrite(Strobe, LOW);
        delayMicroseconds(40);                             
        Spectrum[i] = analogRead(AnalogIn); 
        digitalWrite(Strobe, HIGH);    
        delayMicroseconds(40)                     
       }

But I still get no variations in the readings.
These are now the results:
969 973 975 976 976 976 976
969 973 975 975 975 976 976
969 973 975 975 975 976 976
969 973 975 975 975 976 976
968 973 975 975 975 976 976
969 973 975 975 975 976 976
969 973 975 975 976 976 976
969 973 975 975 975 975 976

It doesn't matter if I connect or disconnect the cable from the audio jack, it keeps on giving the same values :frowning:
I've tried another ic, which is giving me the same results (and yes, the cable from the audio is functioning)

Resha:
Many thanks for the suggestions and tips, but I still have no values reading it.

I've changed the code into:

digitalWrite(ResetPin, HIGH); 

delayMicroseconds(72);  ; 
    digitalWrite(ResetPin, LOW);

for (int i = 0; i < 7; i++)                           
      {
        digitalWrite(Strobe, LOW);
        delayMicroseconds(40);                           
        Spectrum[i] = analogRead(AnalogIn);
        digitalWrite(Strobe, HIGH);   
        delayMicroseconds(40)                   
      }




But I still get no variations in the readings.
These are now the results:
969 973 975 976 976 976 976
969 973 975 975 975 976 976
969 973 975 975 975 976 976
969 973 975 975 975 976 976
968 973 975 975 975 976 976
969 973 975 975 975 976 976
969 973 975 975 976 976 976
969 973 975 975 975 975 976


It doesn't matter if I connect or disconnect the cable from the audio jack, it keeps on giving the same values :-(
I've tried another ic, which is giving me the same results (and yes, the cable from the audio is functioning)

Finally found the solution!
The last code was correct and it was giving me wrong result because of a ... faulty jumper wire

ps: @Tmd3: thanks a lot for pointing me in the right direction !!!!

This is the EXACT same problem I have had for the last two weeks. Haven't had much time to work on the project but was wondering which exact jumper wire caused this problem? Also, glad you got it working :slight_smile: Bet it is awesome 8)

I really don't know which one was faulty.
I took all the jumper wires from the breadboard and used new ones.
Later I tested them with a led, and I think it was or the strobe one or the reset one. I used long wires for these pins and one of the long wires appeared to be faulty