Introduction: Air Pollution and Environmental Monitor
This project is a sensor station that can detect parts per million levels of carbon monoxide, ammonia, and nitrogen dioxide in the air through the Grove Multichannel Gas Sensor (http://www.seeedstudio.com/wiki/Grove_-_Multichann... It also uses the Grove Light Sensor, Temperature Sensor, and Loudness Sensor to monitor your environment. A Grove LCD RGB Backlight display displays the data and a push button allows the user to display the output of each sensor.
This project was initially designed for and funded by the Columbia Engineering Rio Design Challenge with the goal of providing personal monitoring of air and noise pollution by either setting up the sensor in the house or placing the sensor in a case to be used as a backpack clip to monitor pollution wherever the user goes.
Step 1: Assemble Your Parts!
You'll need:
- Arduino Uno
- Arduino Grove Base Shield
- Grove LCD RGB Backlight
- Grove Light Sensor
- Grove Temperature Sensor
- Grove Loudness Sensor
- Grove Multichannel Gas Sensor
- Grove Button
- Connectors for all the Grove sensors and outputs (6)
- Arduino USB cable
- USB power pack/Battery pack for arduino
Step 2: Stack It Up!
Stack the Grove Base Shield on top of the Arduino
Step 3: Plug in the Analog Sensors!
- Use Grove connectors to plug in Light Sensor to A0,
- Temperature Sensor to A1
- Loudness Sensor to A2
Step 4: Plug in the I2C Devices!
- Use Grove connectors to plug in the Multichannel Gas Sensor,
- and the LCD RGB Backlight to I2C sockets
Note: order does not matter since I2C communicates by setting an address rather than being assigned to a specific spot. I have my gas sensor plugged into the leftmost, and the display plugged in to the right of that
Step 5: Plug in the Button!
The button goes in at D8, again connected using the Grove wires
Step 6: Download Libraries
The libraries are in the following links, take a look at the image to see where to download the .zip file for the libraries
Step 7: Add Your Libraries to the Arduino IDE
Go into Sketch --> Include Library --> Add .ZIP Library, and add the two libraries you have just downloaded
Step 8: Add in the Arduino Code
/*
Code for Environmental Sensor that takes air quality, light, temperature, and noise data from the environment to display on a lcd screen */
#include #include "MutichannelGasSensor.h" #include "rgb_lcd.h" rgb_lcd lcd;
const int buttonPin = 8; int buttonPushCounter = 0; int buttonState = 0; int lastButtonState = 0;
void setup() { lcd.begin(16, 2); // set up the LCD's number of columns and rows Serial.begin(9600); // start serial for output lcd.println("power on!"); lcd.noAutoscroll(); mutichannelGasSensor.begin(0x04);//the default I2C address of the slave is 0x04 //mutichannelGasSensor.changeI2cAddr(0x04); mutichannelGasSensor.doCalibrate(); pinMode(buttonPin, INPUT); }
void loop() { float c; float d; float e; int f; float g; int h; float r; float t; float fah; mutichannelGasSensor.powerOn();
buttonState = digitalRead(buttonPin); // compare the buttonState to its previous state if (buttonState != lastButtonState) { if (buttonState == HIGH) { buttonPushCounter++; } // Delay a little bit to avoid bouncing //delay(50); }
if (buttonPushCounter==0){ c = mutichannelGasSensor.measure_NH3(); lcd.setRGB(155,221,255); lcd.print("NH3:"); if(c>=0) lcd.print(c); else lcd.print("invalid"); lcd.print(" ppm");}
if (buttonPushCounter==1){ d = mutichannelGasSensor.measure_CO(); lcd.setRGB(196,216,226); lcd.print("CO:"); if(d>=0) lcd.print(d); else lcd.print("invalid"); lcd.print(" ppm");}
if (buttonPushCounter==2){ e = mutichannelGasSensor.measure_NO2(); lcd.setRGB(204,255,255); lcd.print("NO2:"); if(e>=0) lcd.print(e); else lcd.print("invalid"); lcd.print(" ppm");}
if (buttonPushCounter==3){ f = analogRead(0); lcd.setRGB(182,134,44); lcd.print("Light:"); if(f>=0) lcd.print(f); else lcd.print("invalid"); lcd.print(" units");}
if (buttonPushCounter==4){ g = analogRead(1); r = (float)(1023-g)*10000/g; //resistance calculation t=1/(log(r/10000)/3975+1/298.15)-273.15; //temperature in celsius fah=t*9/5+32; lcd.setRGB(255,102,255); lcd.print("Temp:"); lcd.print(fah); lcd.print(" *F");}
if (buttonPushCounter==5){ g = analogRead(1); r = (float)(1023-g)*10000/g; //resistance calculation t=1/(log(r/10000)/3975+1/298.15)-273.15; //temperature in celsius lcd.setRGB(255,153,255); lcd.print("Temp:"); lcd.print(t); lcd.print(" *C");}
if (buttonPushCounter==6){ h = analogRead(2); lcd.setRGB(8,30,63); lcd.print("Noise:"); if(h>=0) lcd.print(h); else lcd.print("invalid"); lcd.print(" units");}
if (buttonPushCounter==7){ buttonPushCounter=0; lcd.setRGB(255,255,255); } delay(250); lcd.clear(); }
Attachments
Step 9: Upload Your Code!
- Plug the Arduino into the computer
- Make sure your port under tools has selected the correct Arduino
- Open up the Environmental_sensor.ino file in the Arduino IDE
- Upload the code onto your Arduino
Step 10: Use Your Board!
- Unplug the board from the computer
- Plug the USB into a USB power source or use an Arduino battery pack to power your project
- Click the push button to advance through the sensors: NH3 concentration, CO concentration, NO2 concentration, light level, temperature in Fahrenheit, temperature in Celsius, and noise level
Direct any questions to ericltongfb@gmail.com!
Step 11: Make It Rainbow?!?
Within the code, lcd.setRGB(r,g,b); sets the color of the backlight for each sensor readout screen. With this code, you can set the screen to change through the colors of the rainbow.
Red: lcd.setRGB(255,0,0);
Orange: (255,127,0)
Yellow: (255,255,0)
Green: (0,255,0)
Blue: (0,0,255)
Indigo: (75,0,130)
Violet: (143,0,255)
Attachments

Participated in the
Rainbow Contest 2016

Participated in the
First Time Author Contest 2016

Participated in the
Sensors Contest 2016
9 Comments
7 years ago
I am using Grow - Multichannel Gas Sensor . I tested it with lpg gas ,smoke and smoke lighter but it nothing show any concentration of gases .please guide about that sensor how to test it .I have already library of Multi channel Gas Sensor . I connected to vcc and gnd pin of multiple Channel gas sensor to arduino vcc and gnd pins and Scl pins connect Scl pin of arduino and sdl pin connect to sdl of arduino through jamper wires i am not using base shield . sir please share me some information about that sensor.
Reply 7 years ago
The library was recently updated because people were having problems with it. In my case, I noticed that the sensor was shutting itself off every few cycles, so I included a part in the code to force the sensor to be on for every cycle
Reply 6 years ago
Dear sir ,
can you please share the code with me beacuse i try many times but Multichanel gas sensor did not detect any gas concertation
can you mail me code at (gulgul773@rocketmail.com) and also guide me about this sensor how to test this sensor
i am looking forward for you relpy
Reply 7 years ago
Please guide about code and share the code with me and from where I download the updated liabrary
6 years ago
Hi all,
I tried your tutorial but when I upload code on my arduino uno, there is a strange message ( image cf attached )
Thanks you for your help :)
BR
7 years ago
Im torn between the two- Should I used Pi or Arduino for outdoor pollution monitoring?
I have roughly a budget of $120 USD per node. Can I use both of them together?
- If pi. What do you do about battery conservation?
Pushing data to a webpage recomendations?
Uploading data?
What sensors should I use? Ive seen someone trying to sell a single CO2 sensor for $50 USD?!?
CO2, NO, CO, NO2 sensor suggestions?
Ive been looking at grove
Some will be battery powered. others by the mains. im going to try 3D print a case for weatherproofing.
Reply 7 years ago
I think that the arduino is good enough for this application. It also sounds like you're interested in recording measurements from these sensors over time. It might be worth getting a bluetooth or wifi module to connect the arduino and be able to take in the data. Again, raspberry pi has less support for projects like this and tend to be more energy intensive, so the arduino will be enough.
It may be worth looking up reviews for various sensors. I was able to get this particular sensor due to a small grant, but I noticed that it is not always dependable.
Hope the 3D printing goes well! That step is always my favorite part of a project!
7 years ago
I need to make one of these to see just how bad the in my house is.
Reply 7 years ago
Grove actually has several gas sensors you can choose from. The multichannel gas sensor is on the pricier side, but depending on your needs, you can select a gas sensor that might be cheaper and still give you the info that you need