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))
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))
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))
進階搜尋