Temp, Humidity CO2 sensor and library.

Dear All,

I have found the solution to use this sensor with mega 2560!
As Softwareserial notes:
"Note:
Not all pins on the Mega and Mega 2560 support change interrupts,
so only the following can be used for RX:
10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69"

So let's connect the RX pin of the sensor to mega pin 51, and TX pin of the sensor to mega pin 50 and use DirtGambit's sketch with modification:

SoftwareSerial nss(50,51); // TX and RX pins

And smile when you realise this is working fine after calibration!

Thanks, vespapierre! Works like a charm now!

Happy to hear that!!! Great!
Note: if you are using MEGA 2560 board, and you are using ICSP pins ( for example wiznet shield ), than do not use 50 - 51 pins, because ICSP using in this case 50-51-52 pins. So in case try using other pins from the availables( for example 11-12).
Usually pin10 is wiznet, pin4 is sd, pin13 is onboard led on mega...
Anyway I do not know what and where is 62, 63, 64, 65, 66, 67, 68, 69 ... :~

vespapierre:
Anyway I do not know what and where is 62, 63, 64, 65, 66, 67, 68, 69 ... :~

Pin 54 is A0, so pin 62 is A8, 63 is A9, 64 is A10... I just tried out A8-A9, and it works perfectly!
Hope thIS gives you some more options.

aaah thanks! I am testing on pins 11-12. works also perfect :slight_smile:

Hello All. New to this forum and arduino so im at a loss for what im doing wrong.

I've used the new code/re calibration last listed to yield positive CO2 readings, yet my humidity and temperature readings are all 0. Is this an error within the sensor or my doing?

Hi everybody , Recently I've got the cozir wide range

I just read the datasheet and the process to do the calibration part is the same I've used the library provided by
DirtGambit and robtillaart ,my doubt is about this process we need to calibrate the sensor each time I turn on the arduino device or I do need to recalibrate the sensor ?

Thanks for your support.

Hector

hector915:
I've used the library provided by
DirtGambit and robtillaart

Where are these libraries available? They do not seem to be attached to this thread. :frowning:

Hi, I have the same issue as roder have.. I can not find the library cozir.h attached with the post

robtillaart:
yes.
the lib is attached on the first post (it includes the .h file)

Dear robtillaart,
I can not find the cozir.h file attached with the first post. Could you please guide me how can I download this file.

Regards,
Abbas

I have to search for the latest version I have,
"I'll be back"

Attached my latest cozir 0.1.03 lib version. There is a sketch included which compiles.
Disclaimer: I still do not have such sensor so I cannot test it in real life ...

@DirtGambit
Is it OK to include this library in my Github repo?

cozir0.1.03.zip (93.6 KB)

Thanks a lot Rob for the file.
I tried to run it but on monitor nothing is displaying. I am using 1.0.5 version. May be its compatibility issue ?

Dear Rob Tillart,
I tried to run this code http://www.co2meters.com/Documentation/AppNotes/AN128-%20Cozir_Arduino.pdf -

I tried to send the command " z\r\n" to get the co2 values but it didn't work for me so i removed the while condition and it started displaying co2 values

//while(buffer[ind-1] != 0x0A)
{
if(mySerial.available())
{
buffer[ind] = mySerial.read();
ind++;
}
//}

Now when I included the cozir.h file and tried to run this code (posted by @DirtGambit) nothing is displaying on serial monitor. I tried this arduino 1.0.3 as well.

#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);
}

I can't say as I do not have a sensor to verify problems, sorry :frowning:
(reaction on post - 2 :slight_smile:

Try this echo script

#include <SoftwareSerial.h>

SoftwareSerial nss(3,2);

void setup()
{
  Serial.begin(9600); 
  nss.begin(9600);
  delay(3000);
}

void loop()
{
  if (nss.available()) 
  {
    Serial.write(nss.read());
  }
}

does it show anything?

lemme try i ll let u know in a while

yes it displayed this

ÿÿ

I have connected sensor RX -> with Arduino pin#3
and sensor TX _> with pin #2

I added Serial.println("test");

it displayed this text on monitor...
strangely I have to re insert the wire connecting the sensor's RX with microcontroller pin#3 in order to display the text on the serial monitor.

ajaved200:
yes it displayed this

ÿÿ

I have connected sensor RX -> with Arduino pin#3
and sensor TX _> with pin #2

that means you have made a hard wired connection between the hardware Serial and the software serial.
The if statement in the code should do the copying but only if there is data available on the SW serial.
the yy indicates there is nothing to read() (In fact it is ASCII char 255 or -1)