Created
November 3, 2023 02:04
-
-
Save kakopappa/8222c51084122bd9f6b195cb878ae070 to your computer and use it in GitHub Desktop.
Complete tutorial : https://help.sinric.pro/pages/tutorials/air-quality-sensors/mq135.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <TroykaMQ.h> // https://github.com/amperka/TroykaMQ | |
#if defined(ESP8266) | |
#define SENSOR_PIN A0 | |
#elif defined(ESP32) | |
#define SENSOR_PIN 34 | |
#endif | |
MQ135 mq135(SENSOR_PIN); | |
void setup() { | |
Serial.begin(9600); | |
// before calibrating the sensor, warm it up for 60 seconds calibrate the sensor in clean air | |
mq135.calibrate(); | |
// if you know the resistance of the sensor in clean air | |
// you can specify it manually, eg: 160 mq135.calibrate(160); | |
Serial.print("Ro = "); | |
Serial.println(mq135.getRo()); | |
} | |
void loop() { | |
// display gas values in ppm | |
Serial.print(mq135.readCO2()); | |
Serial.println("ppm"); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment