CO2 Engine K33 ICB sending implausible value when using UART

I set up my CO2 engine of the type K33 ICB-F once with analogue output (working just fine) and once with the UART where I cannot figure out what I am doing wrong. I am reading the signal with an Arduino Nano and I always receive the same value of CO2 ppm = 8304. When checking with my multimeter, I see no voltage change on my TX pin at my CO2 engine so apparently there is no signal being sent. What am I doing wrong?

Here is my hardware setup:

My Arduino code I took from an (Instructable) and it looks like this:

// AN-126 Demo of K-30 using Software Serial
#include <SoftwareSerial.h>
/*
 Basic Arduino example for K-Series sensor
 Created by Jason Berger
 Co2meter.com
*/
#include "SoftwareSerial.h"
SoftwareSerial K_30_Serial(1,0); //Sets up a virtual serial port

 
byte readCO2[] = {0xFE, 0X44, 0X00, 0X08, 0X02, 0X9F, 0X25}; //Command packet to read Co2 (see app note)
byte response[] = {0,0,0,0,0,0,0}; //create an array to store the response
//multiplier for value. default is 1. set to 3 for K-30 3% and 10 for K-33 ICB
int valMultiplier = 1;
void setup()
{
 // put your setup code here, to run once:
 Serial.begin(9600); //Opens the main serial port to communicate with the computer
 K_30_Serial.begin(9600); //Opens the virtual serial port with a baud of 9600
 Serial.println(" Demo of AN-126 Software Serial and K-40 Sensor");
}
void loop()
{
 sendRequest(readCO2);
 unsigned long valCO2 = getValue(response);
 Serial.print("Co2 ppm = ");
 Serial.println(valCO2);
 delay(2000);
}
void sendRequest(byte packet[])
{
 while(!K_30_Serial.available()) //keep sending request until we start to get a response
 {
  Serial.println("waiting for Software.serial port availability");
 K_30_Serial.write(readCO2,7);
 delay(50); 
 }
 int timeout=0; //set a timeout counter
 while(K_30_Serial.available() < 7 ) //Wait to get a 7 byte response
 {
 timeout++;
 if(timeout > 10) //if it takes too long there was probably an error
 {
 while(K_30_Serial.available()) //flush whatever we have
 K_30_Serial.read();
 break; //exit and try again
 }
 delay(50);
 }
 for (int i=0; i < 7; i++)
 {
 response[i] = K_30_Serial.read();
 }
}
unsigned long getValue(byte packet[])
{
 int high = packet[3]; //high byte for value is 4th byte in packet in the packet
 int low = packet[4]; //low byte for value is 5th byte in the packet
 unsigned long val = high*256 + low; //Combine high byte and low byte with this formula to get value
 return val* valMultiplier;
}

Your softwareSerial is using the hardware pins (0,1) but you are also using them for normal Serial output. Can't do both.

1 Like

What is wrong is you are using the two pins, 0 and 1, that also are used by your serial.Print() to display on your PC. Pick two other digital pins for your software serial.

1 Like

You do realize that pins 0 and 1 are the programing pins of the Nano?

From the example you claim to be using.

Notice in the image of the code from the example which pins are being used for serial?

1 Like

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