Understanding the equations for the Grove Alcohol Sensor

Ok thanks for your reply.
I think it makes sense now.

I am almost certain that it is a resistance calculation. However, the lack of a resistor value (from a voltage divider equation) confused me.

    Vout = Vin * (R2/(R1+R2))

or if I use their variables, it would look something like this:

    sensor_volt = 5.0 * (RS_air/(R1 + RS_air))


And after shuffling the variables around, I get this:

    RS_air = (sensor_volt * R1) / (5.0 - sensor_volt)


If you look at their equation - they have this:

    RS_air = sensor_volt  / (5.0 - sensor_volt)

As you can see, the R1 is missing from their equation.
Then I suddenly realised (as you pointed out) that they use this RS_air value in a ratio.

Which means that when you divide RS_gas by RS_air, the R1 values cancel out.
So you don't need to know the R1 value - and probably why it is omitted.

I did not know what "R16" was in their code comment. But now it makes sense when you look at the datasheet for the grove sensor (that you highlighted). It is the 10k resistor connected to the MQ303A, alcohol sensor. And I guess it acts like a voltage divider.

Thank you very much for your help.

Now, the next niggling point, that relates to the sensor_volt calculation:

sensor_volt = sensorValue/1024*5.0;

The division by 1024.
You said that the division by 1024 is correct, but the multiplication by 5.0 is not correct.

I think it should be:

sensor_volt = (sensorValue/1023)*5.0;

Mainly because of this tutorial:

But also I thought you could do it this way:

sensor_volt = map(sensorValue, 0, 1023, 0, 5);

Using the map equation found here - you could re-write the above map function like this:

sensor_volt = ((sensorValue - 0) * (5.0 - 0)) / ((1023 - 0) + 0);

Which is the same as:

sensor_volt = (sensorValue * 5.0)/1023

Maybe I have overlooked something here though??