torstai 14. kesäkuuta 2012

IAQ Testing


8.6.2012

For testing the air quality sensor in some closed area and with some chemicals, we (Sumita and I) choose my place. We tested it with three products - Nail polish, Cleaning liquid and Deodorant.

Testing with Nail Polish-
VOC value at the beginning of the test was 115, and on its exposure with nail polish, probably its odor, it reached to 250.

Testing with Cleaning liquid -
At the start of the test, VOC value was at 100 point. We tried with some cleaning liquid in a hand paper towel and kept it near to the sensor. VOC value increased to 202 points. 

Testing with Deodorant - 
We also tested the sensor in a room where we spread anti prespirant alcohol free deodorant. At the start of the test, VOC value was at 100 point and with the deodorant odor it reached till 160. Not much of big difference as in exposure with nail polish and cleaning liquid, but some changes were seen and measured.

Further, we have planned to test the device in some public places. Probably in some restaurants for few hours. As far as tests done till now, it has been revealed that Indoor Air Quality seems to be worse in closed space (indoor area) than in open space with more air circulation though the human crowd is more prominent in open space.

keskiviikko 6. kesäkuuta 2012

Starting testing and setting levels

Hello again,

I have already done some prelimanary testing myself , as I used the system in Demola premises for about an hour, the potentiometer stayed in setting 246 for the whole time, so not much pollutants there I guess, but now is time to move towards the actual testing.

The project is moving towards deadline on 20.6, on which date we will have the final presentation.
Me , Anju and Sumita met today (wed 6.6) and decided some dates considering the testing.
We will have a meeting on Friday 8.6 over the lunch to test the system at the university restaurant. And then do some testing going around the city on Thursday 20.6 , trying the sensoring fro about fifteen minutes in several different places such as market squares, coffee places, fastfood restaurants and bars.
Also when Chris gets back from his holiday before the final meeting, we will finish a demo of the project together.

I found a good list of voc´s to think considering the testing environments:
http://www.health.ny.gov/environmental/indoors/voc.htm

For testing purposes we also need to figure out carefully the levels for the potentiometer we are going to use and stick to them.

Also previously we had followed this one "how to smell pollutants" project partly. Seems the guy behind this project has used the following levels:

"With ~4 days burn-in and ambient temperature of 63F, the values I read in my house were (which is reasonably free of chemical use): 
-sitting in the open air, after sensor warms up for ~1 minute: 52 
-breathing slowly over the sensor for several seconds: 73 
-holding sensor directly over an open bottle of grain alcohol: 235 "

We have currently set our sensor on normal level ~250, where the light is green. Changing to blue at 300. and to red at 350. So maybe we should still recalibrate it a bit if the numbers rise so much when the there is actually voc:s.   Btw. The model of our sensor is: Figaro TGS 2602 , http://www.figarosensor.com/products/2602pdf.pdf

- Mikko

sunnuntai 3. kesäkuuta 2012

Final Serial processing stuff

Ok, so the delay in the Arduino sketch is now 10s as opposed to 0.5 seconds
(last line in sketch is now:   delay(10000); // 10 seconds delay between readings)

The python script creates a file name based on the date + hour and records 1024 values from then on.

final script:


#!/usr/bin/python

import datetime
import serial
import time

# important!!!! set FILEPATH , FILE extension andserial port
FILEPATH = 'C:/Users/Sumita/Desktop/Work/iaq/'
FILEXT = '.txt'
PORT = 'COM3'

# read timeout in seconds
# post is COM3 for windows and  /dev/ttyUSB0 for linux

ser = serial.Serial(port=PORT,baudrate=9600,timeout=20)

# loop forever, well atleast till the Arduino is connected
while True:
    maxread = 1024
    filetime = datetime.datetime.now()
    filename =  FILEPATH + str(filetime.month) + '_' + str(filetime.day) + '_'  + str(filetime.hour) + FILEXT
    file = open(filename, 'a')
    while maxread > 0:
    byte = ser.readline()
    if byte != None:
    byte = int(byte)
    else:
    byte= 0
   
    now = time.time()
    json_data = '{"time":"%s", ' % now
    json_data += '"value":%s}\n' % byte
    print json_data
    file.writelines(json_data)
        maxread -= 1
    file.close()


NOTE: the delay (ins ms) in the arduino sketch should be shorter than the timeout (in s) in the python script!!!
there seems to be an almost 30second delay in writing to the file.. not sure why but doesn't seem a cause for concern

to get this to work: you need Python 2.6 or higher (not 3.0), and pySerial: http://pypi.python.org/pypi/pyserial





Reading the Serial Data


a short python script to read serial value with a timestamp and convert to JSON format:

#!/usr/bin/python

import datetime
import serial
import json

# read timeout in seconds
# post is COM3 for windows and  /dev/ttyUSB0 for linux

ser = serial.Serial(port='COM3',baudrate=9600,timeout=60)

# loop forever, well atleast till the Arduino is connected
while True:
    byte = ser.readline()
    now = datetime.datetime.now()
    json_data = '"datetime":("%s"),' % now
    json_data += '"value":("%s")' % byte
    print json_data

Output:

"datetime":("2012-06-03 22:47:00.149000"),"value":("52")
"datetime":("2012-06-03 22:47:00.613000"),"value":("51")
"datetime":("2012-06-03 22:47:01.070000"),"value":("51")
"datetime":("2012-06-03 22:47:01.558000"),"value":("51")
"datetime":("2012-06-03 22:47:02.019000"),"value":("51")
"datetime":("2012-06-03 22:47:02.494000"),"value":("51")
"datetime":("2012-06-03 22:47:02.984000"),"value":("51")

Now to save it on a file for the Webapp!

Our final code

Looks like this will be our final code: (not much different than v0.1)


// Servo Motor
#include <Servo.h>
Servo myservo;
int pos =0;

// VOC thresholds
const int lowthreshold = 300;
const int highthreshold = 350;

// LED pins
const int RED_LED_PIN = 9;
const int GREEN_LED_PIN = 10;
const int BLUE_LED_PIN = 11;
int gasSensor = A0; // select input pin for gasSensor
int val = 0; // variable to store the value coming from the sensor


int redIntensity = 0;
int greenIntensity = 0;
int blueIntensity = 0;

const int DISPLAY_TIME = 200;

void setup()
{
Serial.begin(9600);
myservo.attach(6);
}

void loop()
{
  val = analogRead(gasSensor); // read the value from the pot
  Serial.println( val );
 
  // green LED is on, when the device is on
    if (val < lowthreshold)
    {
     greenIntensity =255;
     blueIntensity = 0;
     redIntensity =0;
     analogWrite(GREEN_LED_PIN,greenIntensity);
     analogWrite(BLUE_LED_PIN,blueIntensity);
     analogWrite(RED_LED_PIN,redIntensity);
    }
 
  if (val > lowthreshold && val < highthreshold)
    {
     greenIntensity =0;
     redIntensity =0;
     blueIntensity = 255;
     analogWrite(GREEN_LED_PIN,greenIntensity);
     analogWrite(BLUE_LED_PIN,blueIntensity);
     analogWrite(RED_LED_PIN,redIntensity);
   
     // get the motor running
     for (pos=0; pos < 180; pos +=1)
     {
       myservo.write(pos);
       delay(15);
     }
     for (pos=180; pos >= 180; pos -=1)
     {
       myservo.write(pos);
       delay(15);
     }
    }
   
     
  if (val > highthreshold)
    {
     greenIntensity =0;
     blueIntensity = 0;
     redIntensity =255;
     analogWrite(GREEN_LED_PIN,greenIntensity);
     analogWrite(BLUE_LED_PIN,blueIntensity);
     analogWrite(RED_LED_PIN,redIntensity);
   
     // get the motor running
     for (pos=0; pos < 180; pos +=1)
     {
       myservo.write(pos);
       delay(5);
     }
     for (pos=180; pos >= 180; pos -=1)
     {
       myservo.write(pos);
       delay(5);
     }
    }
  delay(500);
}

lauantai 5. toukokuuta 2012

Our Final Circuit

















In our meeting this week (Friday 4th May, 16-18) we got a lot of things done, like finalize our circuit and design.

Now we need a web app, but first, we need to get the data from the serial prompt to a file or an MySql db...

perjantai 4. toukokuuta 2012

The code v.0.1

Hello,

We got the first implementation of the project to work.  The sensor is connected to a rgb-led and a servo-motor. Here´s the code:

// Servo Motor
#include <Servo.h>
Servo myservo;
int pos =0;

// VOC thresholds
const int lowthreshold = 300;
const int highthreshold = 350;

// LED pins
const int RED_LED_PIN = 9;
const int GREEN_LED_PIN = 10;
const int BLUE_LED_PIN = 11;
int gasSensor = A0; // select input pin for gasSensor
int val = 0; // variable to store the value coming from the sensor


int redIntensity = 0;
int greenIntensity = 0;
int blueIntensity = 0;

const int DISPLAY_TIME = 200;

void setup()
{
Serial.begin(9600);
myservo.attach(6);
}

void loop()
{
  val = analogRead(gasSensor); // read the value from the pot
  Serial.println( val );

  // green pin is on when the device is on
  greenIntensity = 255;
  redIntensity =0;
  blueIntensity = 0;
  analogWrite(GREEN_LED_PIN,greenIntensity);
 
  if (val > lowthreshold && val < highthreshold)
    {
     greenIntensity =0;
     redIntensity =0;
     blueIntensity = 255;
     analogWrite(GREEN_LED_PIN,greenIntensity);
     analogWrite(BLUE_LED_PIN,blueIntensity);
     analogWrite(RED_LED_PIN,redIntensity);
    
     // get the motor running
     for (pos=0; pos < 180; pos +=1)
     {
       myservo.write(pos);
       delay(15);
     }
     for (pos=180; pos >= 180; pos -=1)
     {
       myservo.write(pos);
       delay(15);
     }
    }
   
     
  if (val > highthreshold)
    {
     greenIntensity =0;
     blueIntensity = 0;
     redIntensity =255;
     analogWrite(GREEN_LED_PIN,greenIntensity);
     analogWrite(BLUE_LED_PIN,blueIntensity);
     analogWrite(RED_LED_PIN,redIntensity);
    
     // get the motor running
     for (pos=0; pos < 180; pos +=1)
     {
       myservo.write(pos);
       delay(5);
     }
     for (pos=180; pos >= 180; pos -=1)
     {
       myservo.write(pos);
       delay(5);
     }
    }
   
    if (val < lowthreshold)
    {
     greenIntensity =255;
     blueIntensity = 0;
     redIntensity =0;
     analogWrite(GREEN_LED_PIN,greenIntensity);
     analogWrite(BLUE_LED_PIN,blueIntensity);
     analogWrite(RED_LED_PIN,redIntensity);
    }

  delay(500);
/*  for (greenIntensity =0;
       greenIntensity <= 255;
       greenIntensity +=5)
       {
       redIntensity = 255-greenIntensity;
       analogWrite(GREEN_LED_PIN,greenIntensity);
       analogWrite(RED_LED_PIN,redIntensity);
       delay(DISPLAY_TIME);
       }
   for (blueIntensity =0;
       blueIntensity <= 255;
       blueIntensity +=5)
       {
       greenIntensity = 255-blueIntensity;
       analogWrite(BLUE_LED_PIN,blueIntensity);
       analogWrite(GREEN_LED_PIN,greenIntensity);
       delay(DISPLAY_TIME);
       } */
      
}

We have also found a cardboard box for the future testing purposes.