/*NYU ITP - Sensor Workshop - Tom Igoe (fall 2012)
 Datalogging: Manuela Donoso & Luca Shapiro
 Test code for the GAS Sensor MQ-135*/

int pollutionPin = 0; // MQ-135
int pollutionReading = 0;
const int interval = 10*100; // the interval between sensor reads, in ms
long lastReadTime = 0;        // the last time you read the sensor, in ms

void setup() {
  Serial.begin(9600);
  Serial.println ("Pollution:"); 
  Serial.println ("read \t volt"); // GAS readings & voltage
}

void loop() {
  // get the current time in ms:
  long currentTime = millis();
  if (currentTime > lastReadTime + interval) {

    // READ POLLUTION
    pollutionReading = analogRead(pollutionPin);
    Serial.print(pollutionReading, DEC);
    float pollutionVoltage = pollutionReading * 5;
    pollutionVoltage /= 1024.0;
    Serial.print("\t"); 
    Serial.println(pollutionVoltage);

    lastReadTime = millis();
  }
}