Gas sensor MQ-2 is used here with ATmega32 microcontroller to detect gas presence and display the level of the gas on LCD. MQ-2 gas sensor can detect LPG, smoke and hydrogen gas, butane, CO2, alcohol etc so you can use it in many projects. Here we will simply display the level of LPG gas and Smoke in PPM(Parts Per Million) on LCD.
Download the project Proteus File
You can download the project Proteus File from the free download link below.
Dwnload Gas Sensor MQ-2 with ATmega32 and LCD project filesShown below is picture of what it looks like when the circuit is completed on a breadboard.
MQ-2 Gas Sensor Module
Also in the picture you can see a potentiometer knob which is used to adjust the sensitivity of the sensor. Clockwise rotation will increase the sensitivity and counter clockwise rotation will decrease the sensitivity.
Circuit Diagram of Interfacing MQ-2 Gas Sensor with ATmega32 and LCD
Below is the wiring diagram for interfacing MQ2 gas sensor with ATmega32 and LCD. The MQ2 analog output pin is connected to the ADC0 pin which is on PORT A pin 0. From this pin we acquire the sensor signal and convert it to PPM value according the Datasheet of MQ2 sensor. For how to do this see the code provided below. The 16x2 LCD is connected to the Port.D of ATmega32. For this pin PD7 to pin PD2 are used.
Code of MQ-2 gas sensor with ATmega32 and LCD
The following are the codes used for this project. There is main.c file and c and header files for LCD, ADC module and MQ2 sensor.
main.c
lcd.h
lcd.c
adc.h
adc.c
mq2.h
mq2.c
Result & Conclusion
Thus we have successfully used MQ-2 sensor with ATmega32 to display LPG and Smoke level on an LCD. By bringing butane gas near the sensor, the MQ-2 sensor has detected the gas and using the above code, we have displayed the gas and smoke level on the LCD. The following video demonstrates the working of MQ-2 gas sensor with ATmega32 microcontroller and LCD.
Further Work
One can easily modify the code to take action if certain level of gas is reached. For example, you can use DC Motor Control using ATmega32 to run a fan or you can use servo motor or Stepper Motor using ATmega32 to turn on/off supply regulator or open/close window to adjust the gas in the surrounding.
Recommended Tutorial
how can i download protues file
Hello I could not able find protues file
Pls give proper Proteus file this Proteus file goes to other websites
Can you give me all proteus file and tell me version of proteus on jadhavarjun263@gmail.com adress
The link for the proteus file is broken. Could you please provide with another link instead?
hello all,
The following is the link to download. Let me know if any problem downloading:
https://drive.google.com/file/d/1fYW_B82QC_yaxmzbO3hrwIHo2h0pqqIH/view?usp=sharing
can you please tell how to add buzzer to this model which buzzes after certain threshold of ppm? kindly reply
you need to connect the buzzer to some pin like PB0 for example, then in the GetGasPercentage() function or in the main function you can write code to turn on the buzzer when some gas percentage is exceeded.
Sir, can you please provide the code and proteus file for buzzer integrated with it, we are trying but it is not running. we have a deadline on 31th may. it would be very grateful if you respond.
can you please send the code how to interface buzzer to it it would be very helpful.
I have connected everything same as you but in hardwere lpg and somke stays always 0 it doesn't change value.... Please help me
post your picture of your hardware and probably we can help
Hey, what's the value for the crystal oscillator used in this project?
i used crystal with frequency is 4MHz, you can also use internal oscillator, no need for external crystal