Go Down

Topic: Figaro TGS2442 CO sensor help (Read 190 times) previous topic - next topic

V9587

Jun 25, 2019, 10:43 am Last Edit: Jun 25, 2019, 03:41 pm by V9587
hi, i have been trying to make an air quality sensor using the figaro tgs 2442 sensor. however i am a bit confused with a the wiring diagram and the code.
the wiring diagram i used is similar to this: http://habitatmap.org/habitatmap_docs/HowToBuildAnAirCastingAirMonitor.pdf
i wired only the CO sensor for now. and the code is as mentioned below.
the output i get seems to be very wrong. i attached the output image here as well.




Code: [Select]

/*
CO Meter
for Arduino UNO R3 & IDE 1.0.5
by Flavio ... 07/07/2013
*/

int FigaroHeater = 6; // Heat VCC
int FigaroCircuit = 5; // Sensing VCC
int FigaroCOPin = A0;


byte N = 10; // numero di campioni
int Somma; // somma dei campioni (max 32767)

int FigaroCOVal = 0;

void setup() {

Serial.begin(9600);
pinMode(FigaroHeater, OUTPUT);
pinMode(FigaroCircuit, OUTPUT);
pinMode(FigaroCOPin, INPUT);
}

void loop( ) {

digitalWrite(FigaroCircuit, LOW); // turn OFF sensing VCC

analogWrite(FigaroHeater, 245); // turn ON heating (recommended 4.8 volts)
delay(14); // heating time
analogWrite(FigaroHeater, 0); // turn off heating

delay(981); // ritardo prima attivazione di lettura
digitalWrite(FigaroCircuit, HIGH); // turn ON sensing VCC
delay(3); // ritardo prima della lettura

Somma = 0;
for (byte I = 0; I < N; I ++) { // ciclo di letture (@ 8620 sample/s)
Somma += analogRead(FigaroCOPin);
}
FigaroCOVal = Somma / N; // media per eliminazione "rumore" ed errore su prima lettura
Serial.println(FigaroCOVal);// display result (0-1023)
int RL=39000;
int RS;
int Vo = (FigaroCOVal*5)/1024;
RS = ((FigaroCircuit*RL)/Vo);
int COppm = 100/RS;
Serial.println("CO ppm: ");
Serial.println(COppm);
delay(2000);
}

pylon

First: Please edit your post and insert code tags!

Code: [Select]
RS = ((FigaroCircuit*RL)/Vo);

Why is the output pin number used in the formula?

Don't use integer variables if you think yourself in floating point numbers. Your Vo value will be 1 or 2, probably not the accuracy you expected.

Code: [Select]
int RL=39000;

An int variable cannot hold such a big number.

V9587

hi i should adjust those then. Thank you! do you know the proper wiring diagram for this sensor?? because i cannot understand where the input A0 connects to the sensor

pylon

Quote
do you know the proper wiring diagram for this sensor?? because i cannot understand where the input A0 connects to the sensor
I thought you're using the wiring as in the tutorial you linked to? A0 is connected between the sensor and the external resistor.

Go Up