如何使用 MQ135 和 Arduino 查找 Co2 和 O2 水平

Jit*_*ddy 3 arduino-uno iot

如何使用 MQ135 和 Arduino 查找 Co2 和 O2 水平或任何其他参数,我只是感测到 ppm 数据并将其显示在屏幕上。

int sensorValue;
int pin8 = 8;
void setup()
{
  Serial.begin(9600);      // sets the serial port to 9600
  pinMode(pin8, OUTPUT);
}

void loop()
{
  sensorValue = analogRead(0);       // read analog input pin 0
  Serial.print(sensorValue, DEC);  // prints the value read
  Serial.println("ppm");
  if (sensorValue > 500) {
    // Activate digital output pin 8 - the LED will light up
    digitalWrite(pin8, HIGH);
  }
  else {
    // Deactivate digital output pin 8 - the LED will not light up
    digitalWrite(pin8, LOW);
  }

  delay(5000);                        // wait 100ms for next reading
}
Run Code Online (Sandbox Code Playgroud)

Gno*_*tiC 5

我发现,如果您是第一次使用传感器,最好让它通电大约 24 小时,然后才能获得良好的读数。不要跳过这一步。

然后是校准过程。只需校准它即可在良好的空气条件下从analogRead 获得大约 100-150。

正常空气回流 ~100-150
酒精回流 ~700
较轻气体回流 ~750+

编辑:
刚刚注意到这个用于 MQ135 的 Arduino 库可能会有所帮助。

edit2:
我决定也更新我的代码并找到了这个很好的来源。你可以在这里找到所有代码。