Gas Sensor Programming

Hello everyone, im new here. Just wanna ask if someone work with T6615 gas sensor already?

Put your sensor id in the forum search box and search. Besides seeing your post, there is another that references the same device.

The Product documentation for the sensor seems to me to be comprehensive and fairly digestible! :slight_smile:

in the UART communication protocol document I found, on page 8, it actually lists out the request bytes to send and how to interpret the response.

for example, to get the gas_ppm, something like this maybe:
(Compiles, Not tested!)


uint8_t req_GasPPM[5] = {0xFF, 0xFE, 0x02, 0x02, 0x03};

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial1.begin(19200); //Serial1 (MEGA) is connected to T6615 gas sensor

  Serial.print("T6615 gas sensor Example");
}

void loop() {
  uint16_t i = 0, gas_ppm = 0;

  Serial.print("Requesting GAS PPM");

  //send request to CO2 sensor
  for (int j = 0; j < 5; ++j) {
    Serial1.write(req_GasPPM[j]);
  }

  delay(1000); //arbitrary delay

  //wait for complete response to be received
  while (Serial1.available() < 5);

  while (Serial1.available()) {
    ++i;
    uint8_t b = Serial1.read();
    Serial.print(b, HEX);
    Serial.print(" ");
    if (i == 4) {
      gas_ppm = b; //MSByte received
    }
    else if (i == 5) {
      gas_ppm = (gas_ppm << 8) | b; //LSByte received
    }
  }

  if (i > 0) {
    Serial.print("Gas ppm:");
    Serial.println(gas_ppm);
  }
}

hope that helps...

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