Introduction

MQ sensors are physicochemical sensors used to detect a wide variety of gases, pollutants, and smoke in the atmosphere. The sensor contains a heating element whose electrical resistance changes depending on the presence of a pollutant in the air.

Before functioning and providing accurate readings, some sensors need to be preheated.

Here is a summary table of the different types of MQ gas sensors, their warm-up times for proper operation, the gases they can detect, and their sensitivity:

For the rest of the course, we have chosen the MQ-4 sensor as an example. However, all the circuits we present work for all the sensors listed in the table. Indeed, all MQ sensors have the same pins and are controlled in the same way.

The sensor’s pins

Here are the pins of the gas sensor:

  • GND: Connect to the ground (GND) of the Arduino

  • DigitalWrite: The digital output can be used to control the gas sensor using a potentiometer, for example

  • AnalogWrite: The analog output allows you to read the sensor’s gas value

  • VCC: Must be connected to the 5V or 3.3V pin of the Arduino

Display values on the serial monitor

Now let’s see how to display your gas sensor’s readings on the serial monitor:

Gas Detection LEDs

Now let’s see how to create a gas detection system using LEDs. We’ll use 4 LEDs: green, yellow, orange, and red. The program will first turn on the green LED, indicating little or no gas detected, then progressively light up the other LEDs based on the gas percentage measured by the sensor.

Here are the gas percentage thresholds for lighting the LEDs:

  • Green LED: Always on

  • Yellow LED: Turns on at 30% gas detected

  • Orange LED: Turns on at 50% gas detected

  • Red LED: Turns on at 80% gas detected

Smoke Detector

Now let’s see how to create a real smoke detector using a buzzer. The buzzer will turn on when the sensor detects more than 80% gas.