
5
pinMode(heaterSelPin,OUTPUT); // set the heaterSelPin as digital output.
digitalWrite(heaterSelPin,LOW); // Start to heat the sensor
}
void loop() {
float sensor_volt;
float RS_air; // Get the value of RS via in a clear air
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 = sensor_volt/(5.0-sensor_volt); // omit *R16
Serial.print("sensor_volt = ");
Serial.print(sensor_volt);
Serial.println("V");
Serial.print("RS_air = ");
Serial.println(RS_air);
delay(1000);
}
Then, open the monitor of Arduino IDE, you can see some data are printed, write down the value
of RS_air and you need to use it in the following program. During this step, you may pay a while
time to test the value of RS_air.
#define heaterSelPin 15
void setup() {
Serial.begin(9600);
pinMode(heaterSelPin,OUTPUT); // set the heaterSelPin as digital output.
digitalWrite(heaterSelPin,LOW); // Start to heat the sensor
}
void loop() {
float sensor_volt;
float RS_gas; // Get value of RS in a GAS
float ratio; // Get ratio RS_GAS/RS_air