App-Lab Analog (MQ2) Sensor

App-Lab Analog (MQ2) Sensor

App-Lab Analog (MQ2) Sensor
App-Lab Analog (MQ2) Sensor

This gas sensor is used for household gas leak alarms, industrial combustible gas alarms and portable gas detection instruments. And it is suitable for the detection of liquefied gas, benzene, alkane, alcohol, hydrogen, etc., and widely used in various fire alarm systems. The MQ-2 smoke sensor can be accurately a multi-gas detector, and has the advantages of high sensitivity, fast response, good stability, long life, and simple drive circuit. It can detect the concentration of flammable gas and smoke in the range of 300~10000ppm.Meanwhile, it has high sensitivity to natural gas, liquefied petroleum gas and other smoke, especially to alkanes smoke. It must be heated for a period of time before using the smoke sensor, otherwise the output resistance and voltage are not accurate. However, the heating voltage should not be too high, otherwise it will cause my internal signal line to blow.

It is belongs to the tin dioxide semiconductor gas-sensitive material, and belongs to the surface ion type N-type semiconductor. At a certain temperature, tin dioxide adsorbs oxygen in the air and forms negative ion adsorption of oxygen, reducing the electron density in the semiconductor, thereby increasing its resistance value. When in contact with flammable gas in the air and smog, if the potential barrier at the grain boundary is adjusted by the smog, it will cause the surface conductivity to change. With this, information about the presence of smoke or flammable gas can be obtained. The greater the concentration of smoke or flammable gas in the air, the greater the conductivity, and the lower the output resistance, the larger the analog signal output. The sensor comes with a
positioning hole, which is convenient for you to fix the sensor to other devices. In addition, the sensitivity can be adjusted by rotating the potentiometer.

Specifications:
Working voltage: 3.3-5V (DC)
Interface: 4 pins (VCC, GND, D0, A0)
Output signal: digital signal and analog signal
Weight: 7.5g

Equipment:
keyestudio PLUS Control Board*1
Sensor shield* 1
MQ-2 gas sensor * 1
Passive sensor*1
fan module * 1
Yellow LED module * 1
3pin female to female DuPont Lines
USB cable * 1

Test-Code:

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// App-Lab Projects with Analog (MQ-2) Sensor
// Sends data to thorsten-auch.com
// Tested with Arduino IDE 1.8.16
// 11/2021 Thorsten Auch, https://www.thorsten-auch.com
// Hardware Connections (Arduino IDE 1.8.16)
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

void setup(){
  
Serial.begin(9600);                   //set baud rate to 9600
pinMode(11, INPUT);                   //set digital11 to input
pinMode(A0, INPUT);                   //set A0 to input
pinMode(3, OUTPUT);                   //set digital3 to output
pinMode(7, OUTPUT);                   //set digital7 to output
pinMode(6, OUTPUT);                   //set digital6 to output
pinMode(5, OUTPUT);                   //set digital5 to output

}

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

void loop(){
Serial.println(digitalRead(11));      //wrap word and read the analog value of digital 11
Serial.println(analogRead(A0));       //wrap word and read the analog value of A0
delay(500);                           //delay in 500ms
if (analogRead(A0) > 45 && digitalRead(11) == 0) {

//if the analog value of A0 is greater than 45 and the digital value of digital11 is 0
tone(3,131);                          //digital3 outputs the sound of 131HZ
delay(125);                           //delay in 125ms

//set fan to rotate
digitalWrite(7,LOW);
analogWrite(6,200);                   //set the PWM value of digital6 to 200, the bigger the the value of PWM is,the faster the fan rotates
digitalWrite(5,HIGH);                 //set digital5 to high level,LED lights up
delay(200);                           //delay in 200ms
digitalWrite(5,LOW);                  //set digital5 to low level,LED is off
delay(200);                           //delay in 200ms
} else
//otherwise
{
noTone(3);                            //digital3 stops sounding
digitalWrite(5,LOW);                  //set digital5 to low level,LED is off

//fan stops rotating
digitalWrite(7,LOW);
analogWrite(6,0);
}
}

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

What's Your Reaction?

like
1
dislike
0
love
0
funny
0
angry
0
sad
0
wow
0