AquaticTechTank.net

A forum dedicated to design and program aquatic tanks
It is currently Fri Apr 18, 2014 4:22 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 12 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: CO2 sensor!
PostPosted: Fri Dec 14, 2012 8:47 pm 
Offline
Site Admin

Joined: Fri Nov 30, 2012 1:54 pm
Posts: 227
This is the final code for the arduino.
Code:
#include <kSeries.h>

/* Reports values from a K-series sensor back to the computer written by Jason Berger Co2Meter.com
*/
int pin = 8;

kSeries K_30(12,13); //Initialize a kSeries Sensor with pin 12 as Rx and 13 as Tx
void setup()
{
    Serial.begin(9600); //start a serial port to communicate with the computer
    pinMode(pin, OUTPUT);
}

void loop()
{
  double co2 = K_30.getCO2('p'); //returns co2 value in ppm ('p') or percent ('%')
 
  //there's a glitch sometimes with the sensor output
  if(co2 >= 0 && co2 <= 10000) {
      co2 = co2 * 0.8317 * 44.01 / 10000;
      //   converts ppmv to ppmw
      //  quicker than co2/1000000 * 0.8317 * 44.01 / 1000000
      //  0.8317 accounts for Henry's Law
      // max ppmw will be 36.6 with 10,000 ppmv

      //raise from 0 to 36... writes every loop
      if ( co2 < 36 ) {
          digitalWrite(pin, HIGH);
      } else {
          digitalWrite(pin, LOW);

      }
   
  }
 
  Serial.println(co2);   //print value
  delay(1500);   //wait 1.5 seconds

}



I've also attached the K-30 series library for the arduino in case you can't find it on their website.


Attachments:
File comment: KSeries library for the arduino
kSeries.zip [9.71 KiB]
Downloaded 64 times
Top
 Profile  
 
 Post subject: Re: CO2 sensor!
PostPosted: Fri Dec 14, 2012 10:49 pm 
Offline
Site Admin

Joined: Fri Nov 30, 2012 1:54 pm
Posts: 227
Time to build out how the arduino controls a relay. I got a 5v relay from Radio Shack to play with.

Image
Attachment:
arduino_relay.png
arduino_relay.png [ 48.88 KiB | Viewed 842 times ]


It's a but more complicated than I thought. Then I realized I'd need to supply power to the relay AND the sensor from the arduino. Good thing the arduino has a 5v and 3.3V...

So I got this bad boy. All of the circuitry and diode is in the box
Image

So to test things out...
Image

The wiring is a lot less complicate than before.

I then put the whole thing in a power box. For easy connection, I used a telephone 6 pin connector to connect to the arduino.
Image

Hook everything up to a power outlet.
Image

And then test everything out on a desk lamp.

Here's the sensor with the new silicone membrane.
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Copyright 2noodles LLC 2012