solvek / CO2Sensor

Arduino library for modules based on CO2 sensors TGS-4161 or MG-811
11 stars 11 forks source link

For MG-811, produces inconsistent values #2

Open zhekaus opened 5 years ago

zhekaus commented 5 years ago

CO2 value: 0 CO2 value: 0 CO2 value: 0 CO2 value: 0 CO2 value: 18 CO2 value: 1187 CO2 value: 120 CO2 value: 1 CO2 value: 0 CO2 value: 0 CO2 value: 0 CO2 value: 4 CO2 value: 639 CO2 value: 416 CO2 value: 3 CO2 value: 0

frankitox commented 4 years ago

Hey @zhekaus. I'm using this library right now and I'm getting pretty consistent values. Even using 5v with an Arduino Uno. This is the basic code I found and use, maybe it helps you.

#include "CO2Sensor.h"

CO2Sensor co2Sensor(A0, 0.99, 100);

void setup() {
  Serial.begin(9600);
  Serial.println("=== Initialized ===");
  co2Sensor.calibrate();
}

void loop() {
  int val = co2Sensor.read();
  Serial.print("CO2 value: ");
  Serial.println(val);

  delay(1000);
}