MQ-2 MQ2 Gas Sensor Methane Butane Detection
MQ-2 MQ2 Gas Sensor เป็นเซ็นเซอร์ตรวจจับควัน และ ก๊าซธรรมชาติ ส่งค่ากลับมาเป็น Analog กับ Digital สามารถปรับความไวได้ ใช้ในการตรวจวัดควันไฟที่เกิดจากการเผาไหม้เป็นต้น
Module Size: 30×19×20mm/1.18*0.74*0.78"
Input Voltage: DC5V
Power Dissipation: 150mA
DO Output: 0.1-5V
AO Output: 0.1-0.3V
Detectable Concentration: 300-10000ppm
characteristics:
With a signal output instruction
Dual signal output (analog output, and TTL level output)
TTL output
0~5V analog output voltage, the higher the concentration the higher the voltage
The gas, natural gas, city gas, smoke better sensitivity
With a long service life and reliable stability
Rapid response and recovery characteristics
ข้อมูลเพิ่มเติม
ตัวอย่างการใช้งาน
เมื่อมีกลุ่มควัน มาที่บริเวณเซ็นเซอร์ จะมีการส่งสัญญาณ Analog ไปยัง Arduino หากมีความหนาแน่นของ ควัน ยังไม่สูงพอ (ที่ตั้งไว้ 300) ให้ส่งค่าที่วัดได้แต่ไม่ต้องส่งการแจ้งเตือน แต่ถ้าเกินค่าที่ตั้งไว้ 300 ให้ส่งค่าที่วัดได้พร้อมการแจ้งเตือน Smoke detected!
MQ2 -> Arduino
Vcc -> 5V
Gnd -> Gnd
AD -> A0
ตัวอย่างโค้ด
#define MQ2pin (0)
float sensorValue; //variable to store sensor value
void setup()
{
Serial.begin(9600); // sets the serial port to 9600
Serial.println("Gas sensor warming up!");
delay(20000); // allow the MQ-6 to warm up
}
void loop()
{
sensorValue = analogRead(MQ2pin); // read analog input pin 0
Serial.print("Sensor Value: ");
Serial.print(sensorValue);
if(sensorValue > 300)
{
Serial.print(" | Smoke detected!");
}
Serial.println("");
delay(2000); // wait 2s for next reading
}
ผลลัพธ์ การทำงาน