Toggle main menu visibility
臺南市教育局科技教育網
線上書籍
電子相簿
PM2.5監測
IOT實作
OpenID登入
:::
登入
登入
帳號
密碼
登入
使用 臺南市 OpenID 快速登入
:::
所有書籍
「南工高瞻_資料傳輸課程」目錄
MarkDown
1-3 MQ-6
MQTT server Windows 安裝
1. 氣體感測器
1-1 MQ-2
1-2 MQ-4
1-3 MQ-6
1-4 MQ-9
1-5 MQ-135
2. 環境數據上傳
1-5 MQ-135
南工高瞻\_資料傳輸課程 ============ 一、元件介紹 感測:一氧化碳,可燃氣體 
Arduino UNO
MQ-9 元件
A0
A0
不接
D0
GND
GND
5V
VCC
二、接線範例  三、程式範例 Arduino程式參考:[http://wiki.seeed.cc/Grove-Gas\_Sensor-MQ9/](http://wiki.seeed.cc/Grove-Gas_Sensor-MQ9/) 基礎 ``` void setup() { Serial.begin(9600); } void loop() { float sensor_volt; float sensorValue; sensorValue = analogRead(A0); sensor_volt = sensorValue/1024*5.0; Serial.print("sensor_volt = "); Serial.print(sensor_volt); Serial.println("V"); delay(1000); } ``` 測量近似值 1. Keep the Gas Sensor in clean air environment. Upload the program below. ``` void setup() { Serial.begin(9600); } void loop() { float sensor_volt; float RS_air; // Get the value of RS via in a clear air float R0; // Get the value of R0 via in LPG float sensorValue; /*--- Get a average data by testing 100 times ---*/ for(int x = 0 ; x < 100 ; x++) { sensorValue = sensorValue + analogRead(A0); } sensorValue = sensorValue/100.0; /*-----------------------------------------------*/ sensor_volt = sensorValue/1024*5.0; RS_air = (5.0-sensor_volt)/sensor_volt; // omit *RL R0 = RS_air/9.9; // The ratio of RS/R0 is 9.9 in LPG gas from Graph (Found using WebPlotDigitizer) Serial.print("sensor_volt = "); Serial.print(sensor_volt); Serial.println("V"); Serial.print("R0 = "); Serial.println(R0); delay(1000); } ``` 2.
Replace the R0 below with value of R0 tested above
. Expose the sensor to any one of the gas listed above. ``` void setup() { Serial.begin(9600); } void loop() { float sensor_volt; float RS_gas; // Get value of RS in a GAS float ratio; // Get ratio RS_GAS/RS_air int sensorValue = analogRead(A0); sensor_volt=(float)sensorValue/1024*5.0; RS_gas = (5.0-sensor_volt)/sensor_volt; // omit *RL /*-Replace the name "R0" with the value of R0 in the demo of First Test -*/ ratio = RS_gas/R0; // ratio = RS/R0 /*-----------------------------------------------------------------------*/ Serial.print("sensor_volt = "); Serial.println(sensor_volt); Serial.print("RS_ratio = "); Serial.println(RS_gas); Serial.print("Rs/R0 = "); Serial.println(ratio); Serial.print("\n\n"); delay(1000); } ``` 其他程式參考:[https://www.elecrow.com/wiki/index.php?title=Analog\_CO/Combustible\_Gas\_Sensor(MQ9)](https://www.elecrow.com/wiki/index.php?title=Analog_CO/Combustible_Gas_Sensor(MQ9))
搜尋
search
進階搜尋