Dear all,

I'm interested in sketches / libraries with calibration facilities for the TGS2602 (VOC) sensor.

I haven't found a dedicated code so far (nor on internet, nor on this forum).

Many thanks in advance!

Welcome on the forum,

Do you have links to datasheets or other info about the sensor?

if so please post them,

also code for other platforms might be helpful

Hereby the data sheet of the sensor:

I found this code but I'm not sure if the TGS2602 part has the correct calibration rules.

https://github.com/empierre/arduino/blob/master/MQv01dgi_1_4.ino

thanks in advance

Seems that you could strip the sketch from github to only contain the TGS -code.

I saw no code-snippets about calibration.

What I learned from the datasheet is that there are values for which it definitely cannot discriminate between gasses.

I have been using Emmanuel Pierre's code for some time in my project. I believe it works well.

Hello,

I’m the author of the sketch for I try to make something the more generic one could use with gas sensors.

The curve is made out of a power regression, and I try now to document as much as possible how it was calculated, e.g. for the TGS2602 you have the values mesured from the datasheet that went through a power regression such as Xuru Power Regression

```
float C7H8Curve[2] = {37.22590719, 2.078062258}; //TGS2602 (0.3;1)( 0.8;10) (0.4;30)
float H2S_Curve[2] = {0.05566582614,-2.954075758}; //TGS2602 (0.8,0.1) (0.4,1) (0.25,3)
float C2H5OH_quarCurve[2] = {0.5409499131,-2.312489623};//TGS2602 (0.75,1) (0.3,10) (0.17,30)
float NH3_Curve[2] = {0.585030495, -3.448654502 }; //TGS2602 (0.8,1) (0.5,10) (0.3,30)
```

There are discussion on the Mysensors AIQ Sensor presenting the different difficulties that can be seen when working with electrolitic gas sensors such as this one.

The calibration is based on the easier way that is called “clean air sensor”, so ifyou know the average concentration in the outdoor air, and do a calibration on first start, then you have something you can at least rely on, but it will not give you the precise calibration from a reference gas concentration. This is the limit of those sensors.

Best,

emmanuel

Hello all,

Thank you all for your information.

I have analysed a lot of sketches regarding TGS2602 but as epierre already said in the reaction above it is not possible to calibrate this type of sensor in a way that it is technically correct.

I also have had contact with the manufacturer of this sensor and received the full version of the data sheet (11 pages). As you will see in the data sheet --> We have to look for a more practical approach.

Where can I put this document?

Note: In the sketches I found you have to calibrate the sensor before using (preheating + getting the sensor value in clean air). Be award that during this calibration you must also have an environment condition of 20°C / 65%RH otherwise you can't use the characteristic curves of the data sheets. Preheating period is about 7 days!

regards,

float C7H8Curve[2] = {37.22590719, 2.078062258}; //TGS2602 (0.3;1)( 0.8;10) (0.4;30)

float H2S_Curve[2] = {0.05566582614,-2.954075758}; //TGS2602 (0.8,0.1) (0.4,1) (0.25,3)

float C2H5OH_quarCurve[2] = {0.5409499131,-2.312489623};//TGS2602 (0.75,1) (0.3,10) (0.17,30)

float NH3_Curve[2] = {0.585030495, -3.448654502 }; //TGS2602 (0.8,1) (0.5,10) (0.3,30)

I am currently working with the TGS2602. Can someone please explain to me what the first value in the array is for and what the second value of the array is for. I believe that the first is the Rs value and the second is the slope? And how these values correspond to the coordinates in the comments following the arrays. I can see from the data sheet graph that the Y value in the coordinate he posted is actually the x value on the graph and the x value in the coordinate is the y value on the graph however I am not sure how he is collelating the points from the array to the coordinates. Thank you!

it are the coefficients of the formula y = ar[0] * pow(x, ar[1]);

the comments give the datapoints used to get the formula (first one seems not 100% correct)

the formula that I see from the data sheet is y-axis = Rs / Ro such that Rs = ( (Vc/Vrl) -1) * Rl

I am not sure where this formula " y = ar[0] * pow(x, ar[1]); " is from?

cloudCoder:

the formula that I see from the data sheet is y-axis = Rs / Ro such that Rs = ( (Vc/Vrl) -1) * RlI am not sure where this formula " y = ar[0] * pow(x, ar[1]); " is from?

The formula comes from XURU - see post 5 above

Ahh I see! Thank you for that.; I had just skimmed through that page and not actually read it thoroughly. So this is just giving us a rough estimate for those 3 concentrations? Are you aware if anyone has used the formula given by Figaro?