Hiep TruongCarlena VellerJenny Vuong
Published

Lane of Things Group 706

This project is designed to observe the air quality within the Lane Tech basement for JROTC students.

Intermediate15 hours583
Lane of Things Group 706

Things used in this project

Hardware components

DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
Photon
Particle Photon
×1
SparkFun Carbon Monoxide Sensor - MQ-7
×1
SparkFun Optical Dust Sensor - GP2Y1010AU0F
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Schematics

Fritzing

Code

706LOTPHOTON

Arduino
// This #include statement was automatically added by the Particle IDE.
//CO2 sensor
#include <MQ135.h>
#define MQ135_H

// This #include statement was automatically added by the Particle IDE.
//Dust sensor
#include <SharpDustSensor.h>
#define __SHARPDUSTSENSOR_H__

// This #include statement was automatically added by the Particle IDE.
//Humdity and tempature sensor
#include <CarbonLibrary.h>
#include <Adafruit_DHT.h>
#define DHTPIN 4            // what pin we're connected to
#define DHTTYPE DHT22       // DHT 22 (AM2302)

//Carbon monoxide
// These constants won't change.  They're used to give names
// to the pins used:
const int analogInPin = 0;  // Analog input pin that the potentiometer is attached to
const int ledPin = 7;                 // LED connected to digital pin 13

int sensorValue = 0;        // value read from the sensor

//Humdity and tempature sensor
//Sets to which pin to draw data from
DHT dht(DHTPIN, DHTTYPE);

double hum;                 // current hum
double temp;                // current temp

//CO sensor
double carbonMonoxide;

//Dust sensor
/*
 Standalone Sketch to use with a Arduino UNO and a
 Sharp Optical Dust Sensor GP2Y1010AU0F
*/

SharpDustSensor sharp(-1, D0, A2);

int measurePin = 2; //Connect dust sensor to Arduino A2 pin
int ledPower = 0;   //Connect 3 led driver pins of dust sensor to Arduino D0
 
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
 
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;

double dust;

void setup() 
{
    //Humidity and temperature sensor
    Serial.begin(9600);
    pinMode(DHTPIN, INPUT);
    
    Particle.variable("hum", hum);
    Particle.variable("temp", temp);
    
    //CO2 sensor
    Serial.begin(9600);      // sets the serial port to 9600
    Particle.variable("carbonMono", carbonMonoxide);
    
    // initialize serial communications at 9600 bps:
    Serial.begin(9600); 
    pinMode(ledPin, OUTPUT);      // sets the digital pin as output
    
    //Dust sensor
    Serial.begin(9600);
    pinMode(ledPower,OUTPUT);
  
    Particle.variable("dust", dust);
}

void loop() 
{    
    //Humidity and temperature sensor
    double checkHum = dht.getHumidity();
    double checkTemp = dht.getTempFarenheit();
    
    if (checkHum > 0 && checkHum < 100)
        hum = checkHum;
        
    if (checkTemp > 32 && checkTemp < 100)
        temp = checkTemp;
    
    Serial.println("Temp: " + String(checkTemp));
    Serial.println("Hum: " + String(checkHum));
    
    //Dust sensor
    digitalWrite(ledPower,LOW); // power on the LED
    delayMicroseconds(samplingTime);
     
    voMeasured = analogRead(measurePin); // read the dust value
     
    delayMicroseconds(deltaTime);
    digitalWrite(ledPower,HIGH); // turn the LED off
    delayMicroseconds(sleepTime);
    
    // 0 - 5V mapped to 0 - 1023 integer values
    // recover voltage
    calcVoltage = voMeasured * (5.0 / 1024.0);

    // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
    // Chris Nafis (c) 2012
    dustDensity = 0.17 * calcVoltage - 0.1;
    
    //dust = sharp.getDensity();
    dust = 0.17 * calcVoltage - 0.1;

    Serial.print("Raw Signal Value (0-1023): ");
    Serial.println(voMeasured);

    Serial.print(" - Voltage: ");
    Serial.println(calcVoltage);
    
    Serial.print(" - Dust Density: ");
    //Serial.println(dustDensity); // unit: mg/m3
    Serial.println(dust);
    
    //CO2
    // read the analog in value:
    sensorValue = analogRead(analogInPin);            
    // determine alarm status
    if (sensorValue >= 750)
    {
        digitalWrite(ledPin, HIGH);   // sets the LED on
    }
    else
    {
    digitalWrite(ledPin, LOW);    // sets the LED off
    }
  
    carbonMonoxide = sensorValue;
    
    // print the results to the serial monitor:
    Serial.print("sensor = " );                       
    Serial.println(sensorValue);     
    
     
    delay(3000);
    //delay(60000);// wait 60000 ms for next reading(every minute)
}

Credits

Hiep Truong

Hiep Truong

1 project • 0 followers
LoT group 706
Carlena Veller

Carlena Veller

1 project • 0 followers
Jenny Vuong

Jenny Vuong

1 project • 0 followers
Thanks to Jenny Vuong, Carlena Veller, Array of Things, Particle, Motorola Solutions Foundation, and Lane Tech High School.

Comments

Add projectSign up / Login