Go Down

Topic: Temp, Humidity CO2 sensor and library. (Read 58980 times) previous topic - next topic

robtillaart

Hi robtillaart,
...
    Hmm...I'll take a look at the uin16_tCO2(). Is there a way to make it go up to around 650,000 ppm, which is the max for this particular sensor?
definitely there is, however I (still) do not have such sensor so I can try to provide a patch that you should test. (did work earlier in this thread ;)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

robtillaart

in the main sketch change this
Code: [Select]
void loop()
{
  Serial.println("Loop");
  float t = czr.Celsius();
  float f = czr.Fahrenheit();
  float h = czr.Humidity();
  uint32_t c = czr.CO2();
 
  Serial.print("Celcius = ");Serial.println(t);
  Serial.print("Fahrenheit = ");Serial.println(f);
  Serial.print("Humidity = ");Serial.println(h);
  Serial.print("CO2 = ");Serial.println(c);
 
  delay(3000);
}



in cozir.h change this
Code: [Select]
uint32_t CO2();


in cozir.cpp change this
Code: [Select]
uint32_t COZIR::CO2()
{
  return Request("Z");
}

and

Code: [Select]

uint32_t COZIR::Request(const char* s)
{
  Command(s);
  // empty buffer
  buffer[0] = '\0';
  // read answer; there may be a 100ms delay!
  // TODO: PROPER TIMEOUT CODE.
  delay(200);
  int idx = 0;
  while(CZR_Serial.available())
  {
    buffer[idx++] = CZR_Serial.read();
  }
  buffer[idx] = '\0';

  uint32_t rv = 0;
  switch(buffer[0])
  {
    case 'T' :
rv = atoi(&buffer[5]);
            if (buffer[4] == 1) rv += 1000;
// negative values are mapped above 1000..1250 => capture this in Celsius()
break;
default :
rv = atol(&buffer[2]);
break;
  }
  return rv;
}


and change the version number to 0.1.04 if it works  :)


Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Dew321

Hi robtillart,


      Thank you for your advice! The wrap-around is fixed now for the sensor. Also, would you know how exactly the CalibrateFreshAir() function works within this library? Does it calibrate by setting the measured air of the environment to 450 ppm and then basing measurements relative to that, or does it do it some other way?
       I am also looking to try to incorporate a small heating element into the arduino, perhaps through the use of nichrome wire. Would you know any possible sources for code that is able to regulate the temperature of the wire, or any references in general?

       Thanks again for all your help :)

robtillaart

Hi robtillart,

      Thank you for your advice! The wrap-around is fixed now for the sensor.
good to hear!,
I'll make a 0.1.04 version of the library today.


Quote
Also, would you know how exactly the CalibrateFreshAir() function works within this library? Does it calibrate by setting the measured air of the environment to 450 ppm and then basing measurements relative to that, or does it do it some other way?
As said earlier in the thread, I do not have such sensor, so nada hands on experience.


Quote
I am also looking to try to incorporate a small heating element into the arduino, perhaps through the use of nichrome wire. Would you know any possible sources for code that is able to regulate the temperature of the wire, or any references in general?
What is the temperature range you want to control?
How accurate / precise should it be?

You might need a PID controller.


Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

robtillaart

Added the cozir lib to github so it is tracked also outside this thread.
URL: - https://github.com/RobTillaart/Arduino/tree/master/libraries -

current version is 0.1.04,
+ added larger range for CO2()
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up