I Application Description:
MQ2 is the smoke sensor. When the smoke spreads, this sensor senses it and the LED on the MQ2 is shinning. The heavy the smoke is, the quicker the shinning is and vice versa.
II Size: length*width*height
III Core chip: MQ-2 gas sensor probe.:
IV: Features:
1. instruction of signal outputting controlled by LED shinning.
2. dual of signal output (analog output and TTL level output)
3.TTL output effective signal is low level which can be directly connected to IO on the MCU.
4. analog outputs power 5~5V. The higher smoke is, the higher power supply is.
5. high sense of gas, butane, methane, smoke and etc.
6. long life and good stability.
7. quick responds and resume.
V Applicatios:
It is suitable for gas leak detection device in family or factory using. It can be installed in the detectors of gas, butane, methane, propane, alcohol, hudrogen and smoke. It detects combustible gases, smoke in the arange 300 to 10000ppm.
VI MQ2 sensor specifications:
VII MQ2 module schematic:
VIII MQ2 module physical picture:
IX Applications based on stm32 maple:
const int analogInPin = 15; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 7; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
float thickness;
int count,count1;
void setup() {
// initialize serial communications at 9600 bps:
SerialUSB.begin();
pinMode(7, OUTPUT);
}
void loop() {
count1++;
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
if(count1==30)
{
count1=0;
// print the results to the serial monitor:
SerialUSB.print("sensor = " );
SerialUSB.print(sensorValue);
SerialUSB.print("\t output = ");
SerialUSB.println(outputValue);
thickness = 20000-(5000*(1023/(float)sensorValue)-1); //This relationship is wrong,According to demand, own calculations relationship
SerialUSB.print("thicknes = ");
SerialUSB.println( thickness);
}
count++;
if(count>=(255-outputValue))
{
count=0;
}
if(count < (255-outputValue)/2)
{
digitalWrite(7, HIGH); // set the LED on
delay(20);
}
// delay(1023-sensorValue);
else
{
digitalWrite(7, LOW); // set the LED off
delay(20);
}
// delay(1023-sensorValue);
}
X Descriptions of application phenomenon:
1.First, insert the MQ2 module in to STM32 spruce. Downlad programs to STM32 spruce board. The developing environment suits this program is the development board based on stm32 and similar to arduino. We call it Maple.
2. After download, disconnect COM5 (USB virtual serial port), and watch experiment phenomenon.
3. Experiment photos:
Last edited by melody91 (2011-08-30 05:59:13)