Hi everyone,
I am currently following a tutorial from the Seeedstudio Wiki that relates to the Grove Alcohol Sensor.
Look here for reference: Grove - Alcohol Sensor | Seeed Studio Wiki
Here is the code in question:
#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_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);
}
.
.
I understand the sensor_volt equation. Essentially converting the analog reading back to a voltage.
I personally think they should be dividing by 1023, but that is not my question.
My question relates to the next equation.
RS_air = sensor_volt/(5.0-sensor_volt);
I am guessing that they are converting the voltage back to resistance?? Can anyone explain how that equation works, or point me in the right direction ? I am trying to understand how they came up with that equation.
The grove alcohol sensor uses an MQ303A sensor.
Datasheet for the grove module and the MQ303A sensor can be found within the wiki (see link above).
Thanks
Scott