Go Down

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

Simas32

Hey everyone.  First time poster here. 

Currently running the Github library and sample sketch posted by DirtGambit (thanks much).  The COZIR is functioning when I run a sketch shell on my Mega 2560 and hook up the COZIR TX and RX to the hardware serial on the Mega.  The humidity, temp, and CO2 readings all display on the output.  However, when I run the sample sketch, the output is as follows:

Fahrenheit : 32.00
Humidity : 0.00
CO2 : 0
Digital Filter : 0

When I adjust the Digital Filter value, all values change directly with the digital filter value.  I'm stumped.  Please help.

kslstn

@Dew321, I'm not entirely sure if I understand entirely what you want, but I created a sketch for logging to SD card where from 15 measurements only the highest and lowest are saved and an average is calculated for every added measurement, until the measurements for that array are saved. If I'm correct, you want to see the velocity at which change happens, so you only have to divide by time after that. The snippet:

Code: [Select]
  float currentCO2 = (float)czr.CO2();
  if ((currentCO2 < CO2[0]) || (pollsInLog == 1)){// save CO2 if it's the lowest value in this interval.
    CO2[0] = currentCO2;
  }
  CO2[1] = (CO2[1] * (pollsInLog - 1)/pollsInLog) + (currentCO2 / pollsInLog);// calculate and save average
  if (currentCO2 > CO2[2]){// save CO2 if it's the highest value in this interval.
    CO2[2] = currentCO2;
  }


The complete sketch is over here on GitHub.


If others are looking for inspiration for logging measurements to an SD card: check it out :-)

kslstn

#137
Feb 26, 2015, 09:46 am Last Edit: Feb 26, 2015, 11:09 am by kslstn
@Simas, I had that issue too. After setting the sensor to poll mode and starting the calibration manually, everything worked fine with Rob's library.

You can find the sketches to do that here on the forum and in my repo (the SetToPolling and Calibrate sketches).

Edit: Also make sure the sensor is connected to pin 2 and 3. If, after trying the above, you still get the 0 readings, try switching the wires, there was some confusing about Tx and Rx. And give it a bit of time. After it's connected to power, the sensor needs about 5 seconds before it measures correctly.

nitrojet

Simas, how did you get it working with the Mega 2560?

I don't seem to be able to get too far with hardware serial, considering writing from scratch but if you have been able to, please let me know.

Regards

robtillaart

@nitrojet

took a while before I had some time to dive into it. Find attached a version of the library with a slightly modified interface that works for both Software and HardwareSerial; The examples compile on a MEGA

Please give it a try

Rob Tillaart

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

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy