CO2STOP

Scientific research indicates that before our civilization is destroyed by global warming, severe impairment of human cognitive and intellectual abilities will occur sooner. Because of the rapid increase in atmospheric CO2 concentrations, catastrophic effects on the human species will come much faster than for most animals.

Already, CO2 concentrations in our homes can be so high that they impair human cognitive and intellectual abilities. People who work from home, in particular, may be at risk of reduced brain performance. Complex tasks will take longer to complete, and creative work may be of much lower quality.

Currently, the average CO2 concentration in the Northern Hemisphere is about 415 ppm. This is over 100 ppm higher than the level at which humans as a species have evolved and functioned to date on our planet. The conditions of life on Earth to date have not forced humans to evolve to cope with this concentration of CO2. This is the reason why humans do not have adaptive mechanisms capable to compensate fully for the effects of living in a polluted atmosphere. Scientists have focused on studying the greenhouse effect, and fail to recognize that the threat of human intellectual disability may come even sooner, before the glaciers melt.

I ask myself, if I had the opportunity to return to the natural state of the atmosphere for 1 month - with CO2 concentrations below 300 ppm, would the constant feeling of mild, unwarranted stress leave me?

Some studies indicate that after a few hours of being in concentrations above 600 ppm, deterioration in human intellectual performance test scores can be observed. In modern, well-managed office buildings, mechanical ventilation quite efficiently provides workers with at least 450 ppm. Meanwhile, in traditional in residential buildings, the level very often exceeds 600 ppm or even 1000 ppm. Therefore, especially in this period of pandemic, it is worth grabbing matters into our own hands and ensuring that our minds work efficiently.

Of course, one can purchase a CO2 detector as just another household gadget that will quickly end up in the corner, out of our attention. However, it seems to me that a personal effort and commitment of some free time to make your own detector will more productive. By tracking the readings from your own detector, you will experience climate change personally. That's the first step to getting involved in the fight to restore the Earth's natural atmosphere. And to improve your brain's performance.

I personally started to feel the strange effect of carbon dioxide at 700 ppm back in 2018. Unfortunately, there is very little research and scientific studies on this topic. So I decided to take a small step in this direction and at least regularly monitor the CO2 concentration in my apartment.

An additional option of this cheap and simple design is to measure humidity. Too dry air in the house has a negative impact on our well-being, especially during sleep.

If you are interested in the subject, I encourage you to read an interesting scientific article dealing with the influence of CO2 concentration on the performance of human mind:.
‘Fossil Fuel Combustion Is Driving Indoor CO2 Toward Levels Harmful to Human Cognition’



SCHEMATIC

1. ESP32(WROOM-32 DevKit V1) Arduino libraries
2. MH-Z19B Arduino libraries
3.
DHT-22
Arduino libraries
4. SSD1306(LCD OLED 0.96" IIC I2C Yellow-Blue)
Arduino libraries
5.
Botton (dimensions 10x10mm)



SETUP











ARDUINO CODE


  
   

#include <MHZ19.h> 
#include <DHT.h>   
#include <Adafruit_SSD1306.h>
#include <WiFi.h> 
#include <WiFiClient.h>
 


#define SCREEN_WIDTH 128 
#define SCREEN_HEIGHT 64

#define OLED_RESET 21
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,&Wire,OLED_RESET);

#define DHTPIN 4 
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
#define RX_PIN 16                                          
#define TX_PIN 17                                         
#define BAUDRATE 9600   



MHZ19 myMHZ19;                                             
                
HardwareSerial mySerial(1);  

unsigned long getDataTimer = 0;

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

WiFiServer server(80);



int prevVal = LOW, times = 0;
long th, tl, h, l, ppm;
bool IpShown = false;


void setup() {
    
  Serial.begin(9600);
  
  mySerial.begin(BAUDRATE, SERIAL_8N1, RX_PIN, TX_PIN); // ESP32 example
  
  myMHZ19.begin(mySerial); 
  
         
  myMHZ19.autoCalibration(false);  // Turn auto calibration OFF
  
 
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    
    for(;;);
  }
  delay(2000);
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 10);
  display.display(); 
  
  
  Serial.println(F("DHTxx test!"));

  dht.begin();
   
  WiFi.begin(ssid, password);
   
  server.begin();
       
}



void loop()
{
 {
	{
 
   if (millis() - getDataTimer >= 2000) 
    {
  
 if(WiFi.waitForConnectResult() != WL_CONNECTED)
           {
                      WiFi.begin(ssid, password);
            }
      
  Serial.println("------------------");
  Serial.print("local IP: ");  
  Serial.println(WiFi.localIP());   //Show ESP32 IP on serial
  Serial.println("------------------");
  
  if(!IpShown) {
        display.clearDisplay();
        display.setCursor(0, 0);
        display.println(WiFi.localIP());
        display.display();
        delay(5000);
        IpShown = true;
      }
  
  int CO2Unlimited = myMHZ19.getCO2(true, true);
  
  
   Serial.print("CO2: ");
        Serial.print(CO2Unlimited);
        Serial.println(" PPM");

        if(CO2Unlimited != 0)
        {
            /* send/store your data code */
        }
        else
        {
            /* ignore data code */
        }
		
		
	  display.clearDisplay();
      display.setCursor(0, 0);
    if (CO2Unlimited < 1000)
        display.println("CO2:"+String(CO2Unlimited) + "ppm");
        else
        display.println(String(CO2Unlimited) + "ppm");
  
   getDataTimer = millis();   // Update interval
    }
 

  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature() - 4; // Correct the temperature after the device is warm (around -4)
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true) - 7.2;  // Correct the temperature after the device is warm (around -7)

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }

  // Compute heat index in Fahrenheit (the default)
  float hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);

  Serial.print(F("Humidity: "));
  Serial.print(h);
  Serial.print(F("%  Temperature: "));
  Serial.print(t);
  Serial.print(F("°C "));
  Serial.print(f);
  Serial.print(F("°F  Heat index: "));
  Serial.print(hic);
  Serial.print(F("°C "));
  Serial.print(hif);
  Serial.println(F("°F"));


  display.println();
        display.print("hum:");
       display.print(h,1);
         display.println(" %");
       display.print("tem:");
       display.print(t,1);
	    display.print("'C  ");
	   
      }

  display.display();
 }
  
  
 {


  WiFiClient client = server.available();   // listen for incoming clients
  
  
  if (client) 
  { 


Serial.println("Web Client connected ");
String request = client.readStringUntil('\r'); 


client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Access-Control-Allow-Origin: *");
client.println();


//json 
client.print('[');
client.print('{');
client.print('"');
client.print("co2");
client.print('"');
client.print(':');
client.print('"');
client.print(myMHZ19.getCO2(true, true));
client.print('"');
client.print(',');
client.print('"');
client.print("humidity");
client.print('"');
client.print(':');
client.print('"');
client.print(dht.readHumidity());
client.print('"');
client.print(',');
client.print('"');
client.print("temperature");
client.print('"');
client.print(':');
client.print('"');
client.print(dht.readTemperature() -4); // Correct the temperature after the device is warm (around -4)
client.print('"');
client.print(',');
client.print('"');
client.print("fahrenheit");
client.print('"');
client.print(':');
client.print('"');
client.print(dht.readTemperature(true) - 7.2); // Correct the temperature after the device is warm (around -7)
client.print('"');
client.print('}');	
client.print(']');


client.stop();
client.println();
Serial.println("Client disconnected.");
Serial.println("");


  }

 }

} 
  

co2stop_ino.zip
If the wlan router frequently changes the assigned ESP32 IP address, reserve a static IP address for the ESP32 in the router.


application