รหัสสินค้า | A213 |
หมวดหมู่ | เซนเซอร์แก๊ส |
ราคา | 45.00 บาท |
สถานะสินค้า | พร้อมส่ง |
จำนวน | ชิ้น |
Arduino MQ-2 Arduino sensor MQ2 เซนเซอร์ MQ-2 ตรวจจับแก๊สมีเทน
เซนเซอร์ MQ-2 สำหรับตรวจจับแก๊สมีเทน LPG , ควันไฟ ,แก๊ส CO และแก๊สอื่น ๆ ดังตารางนี้
ใช้งานง่ายเพียงแค่จ่ายไฟ 5V ก็จะได้สัญญาณเอาต์พุตออกมาทั้งแบบ digital และแบบ analog สามารถนำค่ามาคำนวนเป็นปริมาณแก๊สแบบ ppm ได้ การใช้งานดังนี้
The MQ-2 gas sensor is sensitive to LPG, i-butane, propane, methane, alcohol, Hydrogen and smoke.
อุปกรณ์ทดลอง Arduino MQ-2 เซนเซอร์แก๊สมีเทน
แบบที่ 1 : Arduino MQ-2 การใช้งานแบบ Digital
เซนเซอร์ MQ-2 เมื่อตรวจจับแก๊สได้ค่าเกินระดับที่ตั้งไว้ จะให้สัญญาณเอาต์พุตออกค่า 0 หรือ 1 ที่ขา D0 สามารถประความไวได้ที่ตัวต้านทานปรับค่าได้บนบอร์ด MQ-2 ตัวอย่างการใช้งาน Arduino MQ2 ดังนี้
1. ต่อวงจรดังรูปนี้
2. อัพโหลดโคดตัวอย่างนี้แล้วดูผลลัพธ์
// Example By ArduinoAll | |
int sensor = 7; // | |
int val = 0; | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
val = digitalRead(sensor); | |
if (val == 0) { | |
Serial.println("MQ-2 Detected"); | |
} | |
delay(200); | |
} |
---
3. ทดลองปล่อยแก๊สมีเทน โดยใช้แก๊สจากไฟเช็คเป็นตัวทดลอง ที่บอร์ดจะมีไฟแสดงผลเมื่อตรวจจับแก๊สได้เป็นไฟ LED ดูผลลัพธ์ที่โมดูล MQ-2 และในโปรแกรม Serial Monitor ดังนี้
แบบที่ 2 : การใช้งาน Arduino MQ-2 แบบ Analog
เซนเซอร์ MQ-2 เมื่อตรวจจับแก๊สได้ จะให้ค่าเอาต์พุตออกมาแบบ analog ค่าระหว่าง 0-5V สามารถใช้ Arduino อ่านค่าจาก MQ-2 ได้ที่ขาแบบ Analog ตัวอย่างดังนี้
1. ต่อวงจรดังรูปนี้
2. อัพโหลดโคดตัวอย่างนี้แล้วดูผลลัพธ์
// Example By ArduinoAll | |
int sensor = A0; // | |
int val = 0; | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
val = analogRead(sensor); | |
Serial.println(val); | |
delay(200); | |
} |
---
3. เปิดดูที่ Serial Plotter แล้วปล่อยแก๊สมีเทนจากไฟแช็ค จะเห็นกราฟแสดงค่าเป็นตัวเลขระหว่าง 0-1023 ตามที่เซนเซอร์ MQ-2 อ่านค่าได้
แบบที่ 3 : Arduino MQ-2 PPM การแปลงค่า MQ-2 เป็นหน่วย PPM
การแปลงค่าเป็นหน่วยวัดที่ได้แบบ Analog ให้เป็นค่าหน่วย PPM ทำได้ดังนี้
ก็อปปี้โคดตัวอย่าง Arduino MQ-2 PPM นี้แล้วดูผลลัพธ์
/*******************Demo for MQ-2 Gas Sensor Module V1.0***************************** | |
Support: Tiequan Shao: support[at]sandboxelectronics.com | |
Lisence: Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) | |
Note: This piece of source code is supposed to be used as a demostration ONLY. More | |
sophisticated calibration is required for industrial field application. | |
Sandbox Electronics 2011-04-25 | |
************************************************************************************/ | |
/************************Hardware Related Macros************************************/ | |
#define MQ_PIN (0) //define which analog input channel you are going to use | |
#define RL_VALUE (5) //define the load resistance on the board, in kilo ohms | |
#define RO_CLEAN_AIR_FACTOR (9.83) //RO_CLEAR_AIR_FACTOR=(Sensor resistance in clean air)/RO, | |
//which is derived from the chart in datasheet | |
/***********************Software Related Macros************************************/ | |
#define CALIBARAION_SAMPLE_TIMES (50) //define how many samples you are going to take in the calibration phase | |
#define CALIBRATION_SAMPLE_INTERVAL (500) //define the time interal(in milisecond) between each samples in the | |
//cablibration phase | |
#define READ_SAMPLE_INTERVAL (50) //define how many samples you are going to take in normal operation | |
#define READ_SAMPLE_TIMES (5) //define the time interal(in milisecond) between each samples in | |
//normal operation | |
/**********************Application Related Macros**********************************/ | |
#define GAS_LPG (0) | |
#define GAS_CO (1) | |
#define GAS_SMOKE (2) | |
/*****************************Globals***********************************************/ | |
float LPGCurve[3] = {2.3, 0.21, -0.47}; //two points are taken from the curve. | |
//with these two points, a line is formed which is "approximately equivalent" | |
//to the original curve. | |
//data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59) | |
float COCurve[3] = {2.3, 0.72, -0.34}; //two points are taken from the curve. | |
//with these two points, a line is formed which is "approximately equivalent" | |
//to the original curve. | |
//data format:{ x, y, slope}; point1: (lg200, 0.72), point2: (lg10000, 0.15) | |
float SmokeCurve[3] = {2.3, 0.53, -0.44}; //two points are taken from the curve. | |
//with these two points, a line is formed which is "approximately equivalent" | |
//to the original curve. | |
//data format:{ x, y, slope}; point1: (lg200, 0.53), point2: (lg10000, -0.22) | |
float Ro = 10; //Ro is initialized to 10 kilo ohms | |
void setup() | |
{ | |
Serial.begin(9600); //UART setup, baudrate = 9600bps | |
Serial.print("Calibrating...\n"); | |
Ro = MQCalibration(MQ_PIN); //Calibrating the sensor. Please make sure the sensor is in clean air | |
//when you perform the calibration | |
Serial.print("Calibration is done...\n"); | |
Serial.print("Ro="); | |
Serial.print(Ro); | |
Serial.print("kohm"); | |
Serial.print("\n"); | |
} | |
void loop() | |
{ | |
Serial.print("LPG:"); | |
Serial.print(MQGetGasPercentage(MQRead(MQ_PIN) / Ro, GAS_LPG) ); | |
Serial.print( "ppm" ); | |
Serial.print(" "); | |
Serial.print("CO:"); | |
Serial.print(MQGetGasPercentage(MQRead(MQ_PIN) / Ro, GAS_CO) ); | |
Serial.print( "ppm" ); | |
Serial.print(" "); | |
Serial.print("SMOKE:"); | |
Serial.print(MQGetGasPercentage(MQRead(MQ_PIN) / Ro, GAS_SMOKE) ); | |
Serial.print( "ppm" ); | |
Serial.print("\n"); | |
delay(200); | |
} | |
/****************** MQResistanceCalculation **************************************** | |
Input: raw_adc - raw value read from adc, which represents the voltage | |
Output: the calculated sensor resistance | |
Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage | |
across the load resistor and its resistance, the resistance of the sensor | |
could be derived. | |
************************************************************************************/ | |
float MQResistanceCalculation(int raw_adc) | |
{ | |
return ( ((float)RL_VALUE * (1023 - raw_adc) / raw_adc)); | |
} | |
/***************************** MQCalibration **************************************** | |
Input: mq_pin - analog channel | |
Output: Ro of the sensor | |
Remarks: This function assumes that the sensor is in clean air. It use | |
MQResistanceCalculation to calculates the sensor resistance in clean air | |
and then divides it with RO_CLEAN_AIR_FACTOR. RO_CLEAN_AIR_FACTOR is about | |
10, which differs slightly between different sensors. | |
************************************************************************************/ | |
float MQCalibration(int mq_pin) | |
{ | |
int i; | |
float val = 0; | |
for (i = 0; i < CALIBARAION_SAMPLE_TIMES; i++) { //take multiple samples | |
val += MQResistanceCalculation(analogRead(mq_pin)); | |
delay(CALIBRATION_SAMPLE_INTERVAL); | |
} | |
val = val / CALIBARAION_SAMPLE_TIMES; //calculate the average value | |
val = val / RO_CLEAN_AIR_FACTOR; //divided by RO_CLEAN_AIR_FACTOR yields the Ro | |
//according to the chart in the datasheet | |
return val; | |
} | |
/***************************** MQRead ********************************************* | |
Input: mq_pin - analog channel | |
Output: Rs of the sensor | |
Remarks: This function use MQResistanceCalculation to caculate the sensor resistenc (Rs). | |
The Rs changes as the sensor is in the different consentration of the target | |
gas. The sample times and the time interval between samples could be configured | |
by changing the definition of the macros. | |
************************************************************************************/ | |
float MQRead(int mq_pin) | |
{ | |
int i; | |
float rs = 0; | |
for (i = 0; i < READ_SAMPLE_TIMES; i++) { | |
rs += MQResistanceCalculation(analogRead(mq_pin)); | |
delay(READ_SAMPLE_INTERVAL); | |
} | |
rs = rs / READ_SAMPLE_TIMES; | |
return rs; | |
} | |
/***************************** MQGetGasPercentage ********************************** | |
Input: rs_ro_ratio - Rs divided by Ro | |
gas_id - target gas type | |
Output: ppm of the target gas | |
Remarks: This function passes different curves to the MQGetPercentage function which | |
calculates the ppm (parts per million) of the target gas. | |
************************************************************************************/ | |
int MQGetGasPercentage(float rs_ro_ratio, int gas_id) | |
{ | |
if ( gas_id == GAS_LPG ) { | |
return MQGetPercentage(rs_ro_ratio, LPGCurve); | |
} else if ( gas_id == GAS_CO ) { | |
return MQGetPercentage(rs_ro_ratio, COCurve); | |
} else if ( gas_id == GAS_SMOKE ) { | |
return MQGetPercentage(rs_ro_ratio, SmokeCurve); | |
} | |
return 0; | |
} | |
/***************************** MQGetPercentage ********************************** | |
Input: rs_ro_ratio - Rs divided by Ro | |
pcurve - pointer to the curve of the target gas | |
Output: ppm of the target gas | |
Remarks: By using the slope and a point of the line. The x(logarithmic value of ppm) | |
of the line could be derived if y(rs_ro_ratio) is provided. As it is a | |
logarithmic coordinate, power of 10 is used to convert the result to non-logarithmic | |
value. | |
************************************************************************************/ | |
int MQGetPercentage(float rs_ro_ratio, float *pcurve) | |
{ | |
return (pow(10, ( ((log(rs_ro_ratio) - pcurve[1]) / pcurve[2]) + pcurve[0]))); | |
} |
---
รายละเอียดโคดตัวอย่างเพิ่มเติมจากที่นี่
จะเห็นว่าเราสามารถใช้เซนเซอร์ MQ2 วัดค่า LPG , CO , SMOKE ได้ในหน่วยของ PPM แล้ว
MQ-2 gas sensor sensitive material used in clean air conductivity is lower tin dioxide (SnO2). When the sensor is present in the environment in which the combustible gas, the sensor's conductivity increases with the concentration of combustible gases in air increases. Using a simple circuit can be converted to the change in conductivity of the gas concentration with the corresponding output signal. MQ-2 gas sensor for gas, propane, hydrogen of high sensitivity, natural gas and other combustible vapors detection is also very satisfactory. The sensor can detect a variety of flammable gas, is a low-cost sensors for a variety of applications.
รายละเอียด Module MQ-2 Smoke methane gas liquefied flammable gas sensor module for arduino
ข้อมูลเพิ่มเติม Module MQ-2 Smoke methane gas liquefied flammable gas sensor module for arduino
ตัวอย่างโคด Arduino Module MQ-2 Smoke methane gas liquefied flammable gas sensor module for arduino
/*
MQ2 -> Arduino
Vcc -> 5V
Gnd -> Gnd
AD -> A0
*/
void setup() {
Serial.begin(9600);
}
void loop() {
float vol;
int sensorValue = analogRead(A0);
vol=(float)sensorValue/1024*5.0;
Serial.println(vol,1);
delay(100);
}
28
จัดส่ง วันอาทิตย์-วันศุกร์
ส่งแบบ EMS ได้รับ 1-2 วัน นับจากวันจัดส่ง
วันจันทร์-ศุกร์ แจ้งโอนก่อน 14.00 น. จัดส่งวันนั้น
แจ้งโอนวันศุกร์ หลัง 14.00 น. และวันเสาร์ จัดส่งวันอาทิตย์
แจ้งโอนวันอาทิตย์ จัดส่งวันจันทร์
ขาย Arduino การตรวจสอบเลขแทรคสินค้า Arduino
ขาย Arduino ใบกำกับภาษี
ขาย Arduino สินค้าทุกชิ้นที่ซื้อกับทางร้าน AllNewStep
สามารถนำไปเบิกกับ หน่วยงานราชการ บริษัท ห้างร้าน ได้อย่างถูกต้อง จึงซื้อได้อย่างมั่นใจ
กรณีที่ไม่ได้นำไปใช้เบิก
สามารถติ๊กออก ข้ามช่องนี้ไม่ต้องกรอกได้ ทางร้านออกเป็น ใบเสร็จรับเงิน / ใบกำกับภาษีฉบับย่อให้ แนบไปพร้อมกับสินค้า
ขาย Arduino ใบกำกับภาษีเต็มรูปแบบ
สำคัญมาก "ข้อมูลใบกำกับภาษีไม่สามารถเปลี่ยนแปลงหรือแก้ไขได้หลังการสั่งซื้อสินค้า"
ขาย Arduino ทางร้าน AllNewStep ออกใบกำกับภาษี/ใบเสร็จรับเงิน ลงวันที่ ที่แจ้งชำระสินค้าให้ลูกค้าทุกครั้งที่ทำรายการสั่งซื้อโดยแนบไปพร้อมสินค้า
ขาย Arduino ข้อมูลสำหรับออกใบกำกับภาษี
ขาย Arduino โปรดตรวจสอบข้อมูลเหล่านี้ให้ชัดเจน ก่อนกรอกข้อมูล เพราะใบกำกับภาษีไม่สามารถเปลี่ยนแปลง หรือแก้ไขได้หลังซื้อสินค้า
*** สำคัญมาก :: ข้อมูลจะต้องมีครบทั้ง 4 อย่างนี้ ถ้าไม่ครบ ทางร้านจำเป็นต้องออกใบกำกับภาษีอย่างย่อ เนื่องจากข้อมูลไม่ครบ
ขาย Arduino วิธีการชำระเงิน
ชำระเงินผ่านธนาคาร เรามีหลายธนาคารให้เลือก ขาย Arduino เพื่ออำนวยความสะดวกให้กับลูกค้า
การทำธุรกรรมของธนาคารต่างสาขาหรือต่างธนาคาร จะมีค่าธรรมเนียมเพิ่ม แล้วแต่ธนาคาร กรณีมีค่าธรรมเนียมรายได้เป็นของธนาคาร ทางร้านไม่ได้ออกค่าธรรมเนียมให้
ถ้าทำธุรกรรมภายในธนาคารเดียวกัน จะเสียค่าธรรมเนียมน้อยที่สุดหรือไม่เสียเลย บางธนาคารจะไม่คิดค่าธรรมเนียมโดยจำกัดว่าฟรีได้กี่ครั้งใน 1 เดือน เช่นฟรีค่าธรรมเนียมเมื่อโอนในธนาคารเดียวกัน 5 ครั้ง/เดือน ผ่านทางตู้ ATM
ดังนั้น ควรเลือกโอนมาที่ธนาคารเดียวกัน จะเสียค่าธรรมเนียมน้อยที่สุดหรือไม่เสียค่าธรรมเนียมตามเงื่อนไขที่ธนาคารกำหนด
ขาย Arduino เมื่อชำระเงินผ่านธนาคารแล้ว
กรุณาแจ้งที่หน้า แจ้งชำระเงิน https://www.allnewstep.com/informpayment
พร้อมแนบสลิป หรือภาพหน้าจอการโอนที่สำเร็จแล้ว ด้วยทุกครั้ง
เพื่อเป็นหลักฐาน และเก็บสลิปหลักฐานการโอนเงินไว้จนกว่าจะได้รับสินค้า
กรณีที่ธนาคารสลิปหมด หรือไม่มีสลิป สามารถแจ้งข้อความ รายละเอียดการโอนเงินได้ที่ เมนู ติดต่อ AllNewStep https://www.allnewstep.com/contactus ทางร้านจะดำเนินการตรวจสอบและรีบจัดส่งให้เร็วที่สุด
แนะนำจ่ายเงินผ่าน PromtPay ฟรีค่าธรรมเนียม หรือน้อยที่สุด Recomment
สแกน QR Code นี่จ่ายได้เลย
ขาย Arduino AllNewStep มีอุปกรณ์สำหรับ Arduio ครบทุกอย่างที่อยากได้ จากทุกแห่งทั่วโลก ในราคาที่ถูกที่สุด รับประกันคุณภาพ เสียเปลี่ยนตัวใหม่ให้ทันที ไม่ต้องรอ ไม่ต้องเสียค่าส่งสินค้ามาเคลม ขาย Arduino ตามรายละเอียดการรับประกันด้านล่างนี้
สินค้าทุกชิ้นมีรับประกัน 30 วัน ซื้อสินค้าจาก AllNewStep มั่นใจได้ รับประกันคุณภาพ ด้วยการมีประกันสินค้าที่ดีกว่าเราได้ตรวจเช็คและรับประกันสินค้าซื้อไปใช้ได้อย่างมั่นใจและสบายใจ เพื่อให้ลูกค้าถูกใจที่สุด
ทั้ง นี้หากมีสินค้าที่ได้รับมีความผิดพลาดอันใด ที่อาจเกิดขึ้นได้ ไม่ว่าจะเป็นอุปกรณ์เสีย หรือความเสียหายระหว่างการส่ง โดยที่ลูกค้าไม่ได้เป็นคนกระทำ AllNewStep รับประกันเปลี่ยนตัวใหม่ให้ทันที ภายใน 30 วันหลังจากได้รับสินค้า พร้อมออกค่าส่งสินค้าให้ ทั้งค่าส่งมา และค่าส่งกลับ ลูกค้าไม่ต้องรับภาระเรื่องค่าจัดส่ง โดยสามารถใช้กล่องเดิมส่งมาได้ โดยมีเงื่อนไขดังนี้