INT 21h

Select language

MQ-2 and MQ-7 sensors for using with ESP8266 or Arduino

№ 11876 В разделах: Electronics ESP8266 от January 3rd, 2023,
В подшивках: , , ,

Judging by the reaction to various gases and the operating algorithm, they are based on the same tin oxide catalyst. Both detected the presence of gas from a lighter, and both identified methanol, ethanol and isopropanol vapors perfectly. The air exhaled by a person does not affect them in any way. When tested with carbon monoxide, only the MQ-7 showed minor changes.

Both sensors have a low- and high-level digital output and an analogue ADC output. It’s clear that the digital output is very easy to read and often you don’t even need a microcontroller for some logic to work, for example, to turn on an alarm through a relay, but with an analog leg it’s not so simple. The level of the output analog signal is regulated by a variable resistance to an acceptable level of the initial signal. No special libraries are required, just use the ADC built into your microcontroller.

#define MQAnalogPin A0
int gasLevelWarning = 300;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int gasLevel = analogRead(MQAnalogPin);
  Serial.print(gasLevel);
  if (gasLevel > gasLevelWarning) {
    Serial.println(": WARNING! GAS LEAK!");
  } else {
    Serial.println(": clean");
  }
  delay(50);
}

Testing

Everywhere it is recommended to preheat the sensor for 2 minutes, after which it can be read.

Нет комментариев »

Leave a Reply

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

*

Облачная платформа
Яндекс.Метрика

Fortune cookie: On SECOND thought, maybe I'll heat up some BAKED BEANS and watch REGIS PHILBIN ... It's GREAT to be ALIVE!!