Simple c02 controller

Newbie and having trouble. I am trying to put together a co2 controller. All I need is the code for the k30 c02 sensor and a light on or off sensor. Lcd display and serial with preset ppm settings. Simple with no temp or other sensors just preset readings, light sensor and a relay to control the regulator. I have Parkinson and its hard do things like this. I can do the wiring and have all the stuff but the code escapes me. I tried to paste together a few programs but they either had too much or not enough and they don’t compile right. This is some of what I have so far.

#include “kSeries.h”
#include <Wire.h>

#define RELAY_ON 0
#define RELAY_OFF 1
// create a variable for each relay. Each relay is associated with a different digital pin
// In this example digital pin 2 is connected to the relay
#define Relay_1 2 // Arduino Digital I/O (digitalRead and digitalWrite) pin number.
kSeries Sensor1(8, 9); // Initialize a kSeries Sensor with pin 8 as Rx and 9 as Tx
// In this example we are calling the sensor “Sensor1”
void setup()
// Open serial communications and wait for port to open:
while (!Serial) {
; // wait for serial port to connect. Needed for the arduino native USB port connection

Serial.println(“AN-216 Example 2: uses the kSeries.h library”);
//-------(Initialize Pins so relays are inactive at reset)----
digitalWrite(Relay_1, RELAY_OFF);
//—( THEN set pins as outputs )----
pinMode(Relay_1, OUTPUT);

if (co2_ppm < 780 && co2_ppm > 0) {
// Open valve if CO2 is too low and there is a CO2 reading
digitalWrite(Relay_1, RELAY_ON);
Serial.print(“valve 1 on,”);
delay(200); // Open valve for 200 milliseconds) if the CO2 level is below
// the set point
digitalWrite(Relay_1, RELAY_OFF);

} else {
digitalWrite(Relay_1, RELAY_OFF);
Serial.print("valve 1 off, ");

Any help would be appreciated.

Have a read of the how to post section and put your code between code tags ..

You don’t have a void loop () anywhere so that program just runs the once

I’d suggest , if you are new, you have a play with the basic examples provided with the IDE . Pasting together a few programs will just cause frustration .

Hi Bilhrt,

I am familiar with the CCS811 CO2 sensor while Google fails to present useful results when I use search terms such as 'K30 CO2 sensor' or 'kSeries Co2 sensor' or 'kseries' .
Can you please supply a picture or documentation of your kSeries device? Also a good photo of your sensor wired to an Arduino would help. Please also explain what you want your device to perform: open a valve of what? A high-pressure CO2 tank? How is that valve powered? Or is the purpose to create a puff of carbon dioxide gas from a small bottle or something else easily controllable with an Arduino?
By the way: CCS811 CO2 sensors are available from SparkFun and Adafruit and well documented by these companies.

regards, Photoncatcher

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.