MQ5 sampling frequency

Hi everyone, I'm working on aproject using the MQ5 gas sensor, and I'd like to know whether I can "ask" for the data to the sensor every time, or it has a kind of limit every certain time.
You know, some sensors, like DHT11 cannot give you data in more than 5 seconds, otherwise, you get wrong data
Let me add the program I did, where I ask to the sensor to make 10 readings in 1 second. I just want to know if the time I'm using is either too short, or the readings I'm asking are also too many, since the datasheet is not providing the info
Thanks in advance

void medicionGas()
{
  unsigned long tempRefCont = millis();
  while ((millis() - tempRefCont) <= 1000)
  {
    for(int i = 0; i < 9; i++ )
    {
    lecturaGas = lecturaGas + analogRead(27);
    tempRef=millis();
    }
    lecturaGas = lecturaGas/10;    
  }
  Serial.println(lecturaGas);
}

the datasheet of that sensor... Helpers don't recognize anonymous sensors.

Posting snippets of the code is a waste of energy. Always post the entire code. All helpers are newbies to Your code and need the surrounding code to "get it".

You are not communicating with mq5. You simply are reading the voltage from the sensor. There is no protocol or i2c communication that takes time.
The sensor will simply continue, no matter how often you read it.
Generally it is good to take an average of 10 measurements or so. Like you do. With a small delay (your delay might be a bit long because other code will not run for 10 seconds).
Why do you set tempRef? It seems to do nothing...

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.