Pages: 1 2 [3] 4   Go Down
Author Topic: Temp, Humidity CO2 sensor and library.  (Read 35371 times)
0 Members and 2 Guests are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi DirtGambit ,
I have some difficulties to work with Cozir unit, to change mode and try in Mode2.
I try to send this lines : mySerial.print("K 2\r\n");
and then verify cozir received the message, expecting Response: "K #\r\n" like explain in " cozir software user's guide"
to test the response, I proceed like following:

//essai pour verifie rchangement de mode
while(buffer[ind-1] != 0x0A)
{
if(mySerial.available())
{
buffer[ind] = mySerial.read();
ind++;
}

for(int i=0; i < ind+1; i++)
{
Serial.write(buffer);//test
Serial.print("\t");
}
but the response is
? ? ?
So, should it be possible to have your library to understand how it works?
Best regards
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi DirtGambit,

I have copied your library and your code, and my Arduino uno is happy with the code. I have attached the sensor to my arduino how you did. But when i look at the readings, they are just repeated every 0.5 Seconds and the co2, humidity and temperature reading first 3 digits are always the same.

Can you please suggest what i could be doing wrong

thank you very much!!
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

a link from the manufacturer - schematic + simple code
see - http://www.co2meters.com/Documentation/AppNotes/AN128-%20Cozir_Arduino.pdf -
Logged

Rob Tillaart

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

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't get it to work, I hope someone can point out what's going wrong.

The sample sketch provided by Cozir, as posted earlier here, gives me weird values:
Code:
Co2 = ovf ppm
Co2 = ovf ppm
Co2 = ovf ppm
Co2 = ovf ppm
Co2 = -1152925184.00 ppm
Co2 = -1152925184.00 ppm
Co2 = ovf ppm
Co2 = ovf ppm
Co2 = ovf ppm
Co2 = ovf ppm
Co2 = ovf ppm
Co2 = ovf ppm
Co2 = ovf ppm
Co2 = ovf ppm
Co2 = ovf ppm
Co2 = ovf ppm
Co2 = -4208868864.00 ppm
Co2 = -4208868864.00 ppm
Co2 = ovf ppm

At first I didn't even get these values, but in the code Rx and Tx seem to be exchanged. Just switch the wires if you get no results at all.

I also tried the sketch in the first post of this topic the library 1.03 by Rob Tillaart & Michael Hawthorne, nothing happens. When I use the same sketch with the old library that's attached with the first post, I get this on my monitor:
Code:
Celcius : 0.00
Fahrenheit : 32.00
Humidity : 0.00
CO2 : 0
Digital Filter : 0

Sometimes after a reset, the values are a bit different, I think due to calibration or lack thereof:
Code:
Celcius : 0.20
Fahrenheit : 32.36
Humidity : 0.20
CO2 : 2
Digital Filter : 2

I uncommented the line below, because I read the sketch is supposed to work with polling and the default mode is streaming. The line implicates it's used to enable polling:
Code:
czr.SetOperatingMode(CZR_POLLING);

However, with the other line activated, to set streaming, I get similar readings:
Code:
Celcius : 0.10
Fahrenheit : 32.18
Humidity : 0.10
CO2 : 1
Digital Filter : 1

« Last Edit: January 29, 2014, 04:03:58 pm by Toledor » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As I still have no such sensor (my wishlist is too long)  I cannot replicate your problem, sorry
Logged

Rob Tillaart

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

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey there!  I need assistance on my project using the COZIR sensor.

The first thing I did was hook up the sensor to my arduino and tested the sample code found on the COZIR website but I am getting the same results as Toledor. I would like the sensor to output co2, temp, and humidity readings.

Question for Dirt Gambit and Jon:

How do I use your C library in my arduino sketch? Is there a certain directory I need to save the library in? When I try to run the sketch that you had posted at first, I get several errors:

test1.ino:2:20: error: cozir.h: No such file or directory
test1:5: error: 'COZIR' does not name a type
test1.ino: In function 'void setup()':
test1:7: error: redefinition of 'void setup()'
Sen_design:32: error: 'void setup()' previously defined here
test1.ino: In function 'void loop()':
test1:15: error: redefinition of 'void loop()'
Sen_design:42: error: 'void loop()' previously defined here
test1:17: error: 'czr' was not declared in this scope

Help would be so much appreciated  smiley
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

about installation of libraries - http://arduino.cc/en/Guide/Libraries -

should be enough to get things compiling.
Logged

Rob Tillaart

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

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the quick response Rob!
I got the code to work in conjunction with the library however I seem to have the same issue that Toledor is having. My readings are :

Celcius : 0.20
Fahrenheit : 32.36
Humidity : 0.20
CO2 : 2
Digital Filter : 2

There is no change to these results, any idea what the cause might be?

Also the polling mode doesn't seem to be working properly . I un-commented the line which allowed the CZR_POLLING mode, however the code still spits out readings infinitely. 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please disregard my last post I just needed to switch my Rx and Tx  to pins 3 and 2 on my arduino board to match with the code  smiley-roll-sweat

However I would still like  to operate in polling mode. I am getting a constant flush of data from the sensor even though I am attempting to operate in polling mode. Here is my sketch:

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

Notice I un-commented the line where CZR_POLLING is. I may be going about the whole process wrong though...
Any ideas?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

apparently your code always return 2. (Fahrenheit is a 0.2Celsius  converted)

I peeked into the library and saw that there are open ends e.g. in the request function (which is at the core)

I have attached a datasheet with another Arduino program, you might give that a try.

* AN128- Cozir_Arduino.pdf (106.06 KB - downloaded 48 times.)
Logged

Rob Tillaart

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm hoping somebody is still looking at this. I want to modify this library to work with hardware serial but there are some things I don't understand. Specifically, the constructor looks very strange.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you explain what is strange in your opinion?
Logged

Rob Tillaart

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

Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello and sorry I havent replied to any posts, i havent touched an arduino for a long time, so tonight i took my COZIR sensor and arduino and had a play around, i indeed got some of the problems that many of the users have been having, i was able to reproduce the errors and quickly found out that the sensor need calibrated, i will include the library to this post that i used tonight and also put some functions in and comment them out so in Setup() you can do calibration or change digital filter.

Here is the code i used for my main sketch

Code:
#include <SoftwareSerial.h>
#include "cozir.h"

SoftwareSerial nss(2,3);
COZIR czr(nss);

void setup()
{
  Serial.begin(9600);
  delay(5000);
  //czr.SetOperatingMode(CZR_POLLING);
  //czr.SetOperatingMode(CZR_STREAMING);
  //czr.CalibrateFreshAir();
 // czr.SetDigiFilter(64);
}

void loop()
{
  delay(4000);
  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);
  Serial.println("");
}

Some of the problems people have been having is due to not calibrating the sensor at first use

Here is a step by step
uncomment czr.SetOperatingMode(CZR_POLLING);
Upload Sketch
comment czr.SetOperatingMode(CZR_POLLING);
and uncomment czr.CalibrateFreshAir();
Upload Sketch
comment czr.CalibrateFreshAir();
Upload sketch
and if you want to change digital filter do the same, as the settings are kept on the sensor you never need to do these again unless you want to. I have found if i uncomment them all the sensor plays up and gives bad values until i comment out and upload the sketch again, i dont know why this is, it would have been such a better sensor if it were polling by default.

I have attached the lib i used tonight to this post

Regards
DirtGambit






* cozir.zip (2.99 KB - downloaded 13 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's what I have:

Arduino Uno R2 + Cozir Ambient + DirtGambit's work: running
Arduino Uno R3 + Cozir Ambient + DirtGambit's work: running
Arduino Mega 2560 R3 + Cozir Ambient + DirtGambit's work: fail

I'm guessing I need a logic inverter, to get a 5V signal on the Mega, since all else failed.

O, and thanks DirtGambit, you made the Cozir sensor a lot easier to use!

Blessings!
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks 34R7 but its Rob Tillaart you need to thank too.

Im glad your having success with the sensor, I tried using the sketch that GSS provided and I couldnt get it to work at all, the library still needs work and Im sure very soon it will happen.

Good luck with your projects.
Logged

Pages: 1 2 [3] 4   Go Up
Jump to: