The objective of this article is to provide a guide on simulating the MQ2 Gas Sensor in Proteus. I have created a model of the MQ2 gas sensor for Proteus, which we can utilize for our tutorial.
MQ2 Gas Sensor
The MQ2 Gas sensor is a type of gas sensor commonly used for detecting multiple gases such as methane, butane, propane, alcohol, smoke, and carbon monoxide. It consists of a sensitive layer made of tin dioxide (SnO2) that reacts with the gases in the environment, causing a change in the sensor’s electrical resistance. This change is then measured and interpreted to determine the concentration of the target gas. The MQ2 sensor is widely used in applications such as gas leakage detection, fire detection, and air quality monitoring.
I have found the datasheet of the MQ2 gas sensor on the Pololu electronics and robotics site. Here is the link to the file.
Proteus Model
The MQ2 sensor usually includes a comparator module. This module lets you turn the analog signal into digital output using the LM393 IC. It has a potentiometer to adjust the sensitivity of the digital output. You can set a threshold with this potentiometer. If the gas concentration goes above the threshold, the module outputs LOW; if not, it outputs HIGH.
The MQ2 sensor provides only analog output. Therefore, I have designed a sensor model without the comparator module.
The analog output voltage, obtainable from the A0 pin, varies based on the concentration of the gas or smoke it detects. Hence, when the gas concentration increases, the output voltage rises accordingly. Conversely, as the gas concentration diminishes, the output voltage decreases. This feature offers a convenient method to gauge the presence of specific gases in the environment, simply by monitoring the voltage.
I have included the load resistor within the sensor, allowing you to select it from the properties menu.
How to Use it.
Connect the A0 pin of the sensor to any Arduino analog pin, and connect the supply pins, V+ and GND, to their respective connections. Here’s a simple Arduino code to read the analog output of the MQ2 sensor:
Here is the simulation result:
LM393 Comparator Module
This is the gas sensor circuit with a comparator module. You can set a threshold by using a potentiometer so that when the sensor resistance goes below the comparator threshold value, the module will output LOW; otherwise, it will output HIGH. You can connect this pin with Arduino, or you can directly use the Arduino relay module to control other devices.
Download Library
Simply click on the button to download the library. You can refer to this post for instructions on how to install the library in Proteus 8. How to Download and install Library in Proteus (electronicstree.com)
Please wait 120 seconds: after that, your download will begin ⏳
ZIP Password : electronicstree.com
If you have any requests for Arduino Module Libraries in Proteus, please leave a comment or message us using the contact form.