View Single Post
Old 04-01-14, 08:33 PM   #1
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default GE T6603-5 CO2 sensor Arduino sketch

Code:
/*
GE T6603-5 Safe-AirTM Plus CO2 Sensor

This sensor: +5vdc on pin 3, Gnd on pin 4, 
produces an open collector +Pulse output on pin 5  (with 10K pullup resistor to +5)
The duration of this pulse indicates the CO2 in Parts per Million (with manipulation)

This sketch averages 100 samples & prints out PPM  Takes about 1.7 minutes / printout

http://www.sensorexpert.com.cn/Uploa...2843_18796.pdf

http://www.tecnosens.it/media/6970/920-6603.pdf

Arduino - PulseIn

*/

#define sample_cnt 100
int I;
float sample_avg = 0.0;
float sample_accum = 0.0;
float sample = 0.0;
float ppm = 0.0;

int pin = 11;
 
unsigned long duration;


void setup()
{
  Serial.begin(9600); // start serial communication

  pinMode(pin, INPUT);
  
  delay(5000); 
  
  Serial.println("........Hello world!.......");
}

void loop()
{

sample_accum = 0.0;                    //clear accumulator

for (I = 0; I < sample_cnt ; I++)      //loop taking samples
{    
duration = pulseIn(pin, HIGH);        //read the pulse in microseconds

sample = (duration / 1000.0);        //convert to ms

ppm = (1.996 * sample);              //convert to ppm

sample_accum += ppm;                  //accumulate samples
}

sample_avg = (sample_accum / sample_cnt);  //find average


Serial.print("CO2 level = ");      // Write ppm to serial monitor
Serial.print(sample_avg); 
Serial.println(" ppm"); 
Serial.println("..............");

}


Last edited by buffalobillpatrick; 04-02-14 at 02:54 PM..
buffalobillpatrick is offline   Reply With Quote