Hi, I thought I’d make a post about a sensor I recently purchased and its compatibility with arduino.
I was on the lookout for a sensor that would do temperature, humidity and co2. As I was looking for an all in one solution I settled on the cozir range of sensors http://www.cozir.com. After looking at the datasheet I thought it would interface easily with the arduino. I purchased mine directly from Gas Sensing Solutions. It works on the Arduino 3.3v, GND, and 2 digital pins for software serial TX,RX it took about 2 minutes to attach it and get it working.
As soon as I hooked it up I started the SoftwareSerial example and after a minor modification the sensor was outputting the environment variables in streaming mode, this is the default mode, in this mode it sends out a stream of data at about two per second, as I was wanting to get the data at a time that suits my sketch I put the sensor in polling mode, this allowed me more control over what was happening, once set in polling mode it stays on this mode until you change it which was handy as I could set the sensor up in a separate sketch then I don’t have to worry about including extra code in my project sketch.
I spoke with Rob Tillaart on the forum about it and he suggested a library be made, I had already hacked up my own library but it was a first version to get all the functionality of the sensor like changing digital filter and calibration into my project, Rob provided a blueprint library to start off with plus code which we worked on and tested for the last few weeks.
I have attached the library as a zip file in this post, It is 1.0 compatible. Thanks go out to Rob.
A few things to note, the sensor takes about 2 seconds to warm up, before that expect -100 for temp, putting a 2-3 second delay in setup stops this happening. Streaming mode hasn't been implemented in this version of the library, you can easily choose streaming mode from within the library but if you do you'll have to parse the data yourself, this will be getting worked on over the next few weeks. The digital filtered c02 value by default is set to 32, I found my graphs were moving quite a bit and after testing I have settled on 128, it gives a nice smooth output. Calibration with fresh air, nitrogen and known concentration are also implemented in this version of the lib and when you first power up the sensor you will have to calibrate it.
Please read the datasheet and software user guide before using this library.
Datasheet : http://www.co2meters.com/Documentation/Datasheets/COZIR-Data-Sheet-RevC.pdf
Software User Guide : http://www.co2meters.com/Documentation/Manuals/COZIR-Software-User-Guide-AL12-RevA.pdf
Here is a basic sketch to get it all outputting on the serial.
#include <SoftwareSerial.h>
#include "cozir.h"
SoftwareSerial nss(3,2);
COZIR czr(nss);
void setup()
{
Serial.begin(9600);
delay(3000);
//czr.SetOperatingMode(CZR_POLLING);
//czr.SetOperatingMode(CZR_STREAMING);
}
void loop()
{
float t = czr.Celsius();
float f = czr.Fahrenheit();
float h = czr.Humidity();
int c = czr.CO2();
int digi = czr.GetDigiFilter();
Serial.print("Celcius : ");Serial.println(t);
Serial.print("Fahrenheit : ");Serial.println(f);
Serial.print("Humidity : ");Serial.println(h);
Serial.print("CO2 : ");Serial.println(c);
Serial.print("Digital Filter : ");Serial.println(digi);
}
Enjoy!!!!
Cozir 0-1-01.zip (2.99 KB)