MQ-135 sensor (aka CO2 monitoring)

TLDR: I'm monitoring the amount of CO2 in our house, check it out live here:

Recently bought an MQ-135 sensor off aliexpress. Followed this guide to calibrate it:

My calibration:

/// MQ135.h
/// Calibration resistance at atmospheric CO2 level
//#define RZERO 76.63
#define RZERO 263.82

Then mounted the MQ-135 on a spare Wemos D1 I had lying around and wrote the following:

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include "MQ135.h"

MQ135 gasSensor = MQ135(A0);

const char* ssid = "...";  
const char* password = "...";

IPAddress ip(192,168,1,211); // Static IP we want to give the ESP module  
IPAddress gateway(192,168,1,1);  
IPAddress subnet(255,255,255,0);

ESP8266WebServer server(80);

const int led = 13;

void handleRoot() {  
  digitalWrite(led, 1);
  float ppm = gasSensor.getPPM();
  String ppmString = String(ppm, 0) + "\n";
  server.send(200, "text/plain", ppmString);
  digitalWrite(led, 0);

void handleNotFound(){  
  digitalWrite(led, 1);
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  server.send(404, "text/plain", message);
  digitalWrite(led, 0);

void setup(void){  
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  WiFi.begin(ssid, password);
  WiFi.config(ip, gateway, subnet);

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
  Serial.print("Connected to ");
  Serial.print("IP address: ");

  if (MDNS.begin("esp8266")) {
    Serial.println("MDNS responder started");

  server.on("/", handleRoot);


  Serial.println("HTTP server started");

void loop(void){  

A script which does a curl to every minute and outputs the value to influxdb gives us:

Grafana image

Added a warning threshold of 800ppm and a critical threshold of 1000pm since that seems to be what the WHO considers safe values for inside (outside value + 600) and the current normal outside value is around 400 (as you can see in the last hours of the graph, since that was taken when the windows were open)