//Connect VP to AOUT of AIR QUALITY SENSOR  & OLED SCL=22,SDA=21
#include <WiFi.h> 
#include <Wire.h> 
#include "MQ135.h" 
#include <Adafruit_GFX.h> 
#include <Adafruit_SSD1306.h> 
 
#define SCREEN_WIDTH 128    // OLED display width, in pixels 
#define SCREEN_HEIGHT 64    // OLED display height, in pixels 
#define OLED_RESET -1       // Reset pin # (or -1 if sharing Arduino reset pin) 
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); 
 
void setup() 
{ 
  Serial.begin(115200); 
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64) 
  display.clearDisplay(); 
  delay(10); 
} 
 
void loop() 
{ 
  MQ135 gasSensor(A0); 
  float air_quality = gasSensor.getPPM(); 
  Serial.print("Air Quality: "); 
  Serial.print(air_quality); 
  Serial.println(" PPM"); 
  Serial.println(); 
 
  display.clearDisplay(); 
  display.setCursor(0, 0); //oled display 
  display.setTextSize(1); 
  display.setTextColor(SSD1306_WHITE); 
  display.println("Present Air Quality"); 
 
  display.setCursor(0, 20); //oled display 
  display.setTextSize(2); 
  display.setTextColor(SSD1306_WHITE); 
  display.print(air_quality); 
  display.setTextSize(1); 
  display.setTextColor(SSD1306_WHITE); 
  display.println(" PPM"); 
  display.display(); 
 

 
  delay(2000); // ThingSpeak needs a minimum 15-second delay between updates 
}
