Hi, this is my first post so please excuse any errors I might be making here or in my code.
As a small part of a far larger system what I'm trying to do is read the CO2 ppm levels from to k30 sensors from CO2meter.com. That website handily provides an example of interfacing with a single CO2 sensor using the kSeries.h library that they provide. (Unfortunately, despite several emails, their customer service has been unable to provide a helpful answer to my specific issue.)
The Arduino interface example they show is the 5th note down on this webpage, AN126: Indoor Air Quality Products | CO2Meter.com
They also provide the library there as well. This all works perfectly with a single sensor. My problem is that, being a total Arduino novice, I have absolutely no knowledge of how to alter the example code (or the kSeries library itself) to allow two separate getco2 commands to poll to separate sensors.
Here's the example code:
/*
Reports values from a K-series sensor back to the computer
written by Jason Berger
Co2Meter.com
*/
#include "kSeries.h" //include kSeries Library
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
Serial.println("Serial Up!");
}
void loop()
{
double co2 = K_30.getCO2('p'); //returns co2 value in ppm ('p') or percent ('%')
Serial.print("Co2 ppm = ");
Serial.println(co2); //print value
delay(60000); //wait 1 minute
}
And here's my code, altered to write the values to a LCD (hopefully):
/*
Tries to report values from TWO K-series sensors to an LCD
altered by James
*/
#include "kSeries.h" //include kSeries Library
#include <LiquidCrystal.h>
kSeries K_30a(12,13); //Initialize a kSeries Sensor with pin 12 as Rx1 and 13 as Tx1
kSeries K_30b(8,9); //Initialize a kSeries Sensor with pin 9 as Rx2 and 8 as Tx2
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // initialize the library with the numbers of the interface pins
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.print("Starting up");
}
void loop()
{
double co2a = K_30a.getCO2('p'); //returns co2 value in ppm ('p') or percent ('%')
double co2b = K_30b.getCO2('p');
lcd.setCursor(0, 1);
lcd.print("CO2-in:");
lcd.setCursor(1, 1);
lcd.print("CO2-out:");
lcd.setCursor(0, 8);
lcd.print(co2a);
lcd.setCursor(1, 9);
lcd.print(co2b);
delay(30000); //wait 30 seconds
}
For now I've tried to initialize the two different sensors, calling them kSeries k_30a and kSeries k_30b. Obviously they need different pins, which I've altered, but from there I have essentially no idea how to make this work. What I need is to be able to fill the two different double variables that I'm calling co2a and co2b. From there, printing that data to the LCD should be fairly easy... right?
NOTE: I realize that the pins overlap between the lcd and the sensors, all the numbers are just placeholders for now while I figure out the code... The LCD will use an Adafruit LCD backpack so it won't need as many pins.
So, bottom line, based on the kSeries library and the two sensors that I have, what do I need to change to get this to work?
Any help at all would really be appreciated, thanks!
James