Adruino Project : Pollution Sensor System, initial setup.

I had an Adruino kit lying around for a long time but never did anything with it. Few days back I bought a few sensors and started to build a pollution sensor system consisting of atleast two sensors for now and multiple ways of monitoring. I don’t know any programing and most of the code is copied from different sources and modified wherever required to suit my requirements. As I worked, it became clear that it is not as easy job, so this project is going to be split in to multiple steps.

This project uses two different sensors, a simple MQ135 and a Sharp GP2Y1010. Data sheets are easily available on internet, but for quick reading here are short descriptions:

MQ135: It is a simple sensor used to measure presence of some common pollutants like NH3, NOx, Alcohol, Benzene, Smoke, CO2.  It has 4 pins, two for power supply and 2 for analog and digital readings.

Sharp GP2Y1010 is an optical dust sensor which measures the volume of suspended dust particles in air by using a LED and phototransistor. It has 6 pins.

Adruino pollution sensor project with MQ135 and Sharp GP2Y1010

BASICS:

1 POWER SUPPLY: As of now, Adruino is powered by a USB cable connected to PC. I also have a 9V compatible power supply which can be used once it’s disconnected from PC. I have a old powered USB hub which I plan to use in order to supply a 5V supply later to some components which will be added later. This may be necessary as some components seem to require a bit more power than what is good for accurate readings.

2. ADRUINO : A basic Adruino Uno board.

3. BASE: As of now, I am using breadboard for prototyping stage. If everything goes well, I may rebuild it in a more permanent way.

4. OUTPUT: All the output is being sent to Serial Monitor of Arduino programming interface. A LCD screen and an internet server interface will be added later.

Sharp GP2Y1010 Configuration

  • Pin 1 – Connected to +ve of 220 microF capacitor. -ve of capacitor connected to ground. A 150 Ohm resistor connected to 5 V.
  • Pin 2 – Connected to  -ve of capacitor
  • Pin 3 – Connected to D11 on Adruino
  • Pin 4 – Connected to ground.
  • Pin 5 – Connected to A0 on Adruino
  • Pin 6 – Connected to 5V

CODE:


int measurePin = 0; // Connected to pin 3
int ledPower = 11;  // Connected to pin 5
 
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
 
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
 
void setup(){
  Serial.begin(9600);
  pinMode(ledPower,OUTPUT);
}
 
void loop(){
  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);
 
  // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/


  dustDensity = 0.17 * calcVoltage – 0.1;
 
  Serial.print(“Raw Signal Value (0-1023): “);
  Serial.print(voMeasured);
 
  Serial.print(” – Voltage: “);
  Serial.print(calcVoltage);
 
  Serial.print(” – Dust Density: “);
  Serial.println(dustDensity);
 
  delay(1000);
}


OUTPUT:
NORMAL

  • 20:41:58.934 -> Raw Signal Value (0-1023): 180.00 – Voltage: 0.88 – Dust Density: 0.05
  • 20:41:59.950 -> Raw Signal Value (0-1023): 190.00 – Voltage: 0.93 – Dust Density: 0.06
  • 20:42:00.967 -> Raw Signal Value (0-1023): 175.00 – Voltage: 0.85 – Dust Density: 0.05
  • 20:42:01.981 -> Raw Signal Value (0-1023): 182.00 – Voltage: 0.89 – Dust Density: 0.05
  • 20:42:02.996 -> Raw Signal Value (0-1023): 175.00 – Voltage: 0.85 – Dust Density: 0.05
  • 20:42:04.009 -> Raw Signal Value (0-1023): 174.00 – Voltage: 0.85 – Dust Density: 0.04
  • 20:42:05.025 -> Raw Signal Value (0-1023): 173.00 – Voltage: 0.84 – Dust Density: 0.04
  • 20:42:06.036 -> Raw Signal Value (0-1023): 162.00 – Voltage: 0.79 – Dust Density: 0.03
  • 20:42:07.081 -> Raw Signal Value (0-1023): 176.00 – Voltage: 0.86 – Dust Density: 0.05
  • 20:42:08.096 -> Raw Signal Value (0-1023): 170.00 – Voltage: 0.83 – Dust Density: 0.04

As the voltage level fluctuates the dust density readings change accordingly. I burnt a small piece of paper to see if reading schange and they did.


MAXIMUM VALUE 

To get maximum values, I inserted a piece of rolled paper to block the sensor. Voltage readings jump to their maximum value, 3.69 volts and output dust reading is 0.53 at it’s maximum corresponding value.

  • 20:43:33.582 -> Raw Signal Value (0-1023): 755.00 – Voltage: 3.69 – Dust Density: 0.53
  • 20:43:34.598 -> Raw Signal Value (0-1023): 756.00 – Voltage: 3.69 – Dust Density: 0.53
  • 20:43:35.645 -> Raw Signal Value (0-1023): 755.00 – Voltage: 3.69 – Dust Density: 0.53
  • 20:43:36.659 -> Raw Signal Value (0-1023): 755.00 – Voltage: 3.69 – Dust Density: 0.53
  • 20:43:37.673 -> Raw Signal Value (0-1023): 755.00 – Voltage: 3.69 – Dust Density: 0.53
  • 20:43:38.688 -> Raw Signal Value (0-1023): 756.00 – Voltage: 3.69 – Dust Density: 0.53
  • 20:43:39.704 -> Raw Signal Value (0-1023): 755.00 – Voltage: 3.69 – Dust Density: 0.53



MQ135 Pollution Sensor Configuration

  • Vcc – To 5 V
  • GND –  To Ground
  • A – To A1
  • D – Not connected

CODE:


int sensorValue;
int digitalValue;
void setup()
{

Serial.begin(9600); // sets the serial port to 9600
}
void loop()
{
sensorValue = analogRead(1); // read analog input pin 1
Serial.println(sensorValue, DEC); // prints the value read
Serial.println(digitalValue, DEC);
delay(1000); // wait 100ms for next reading
}


OUTPUT

  • 22:40:14.593 -> 105
  • 22:40:14.593 -> 1
  • 22:40:15.608 -> 105
  • 22:40:15.608 -> 1
  • 22:40:16.589 -> 105
  • 22:40:16.589 -> 1
  • 22:40:17.607 -> 104
  • 22:40:17.607 -> 1
  • 22:40:18.589 -> 104

RESULTS:

By themselves, both sensors work fine. The readings seem to be consistent with environmental conditions and change with changing level of pollutants like smoke.

TO BE DONE:

  1. Attach a LCD screen and output the reading directly to it without use of PC.
  2. Adding and configuring a WiFi module to upload data to an online monitoring application.

PROBLEMS TO BE SOLVED:

  1. There is a noticeable change in readings if both sensors are used at same time. Adruino doesn’t seem to be able to supply same amount of voltage to multiple components. It will affect readings adversely when more components like LCD screen are added. Perhaps use of a separate power source, like a powered USB hub supplying 5 V will help.
  2. I don’t know of any way to properly calibrate the sensors. These are just the raw readings and may not be entirely accurate. I have not figured out a way to address this issue yet.

More in next post.

Leave a Reply