Vous êtes sur la page 1sur 17

Air Quality Measurements Project

Setup
Parts:

1. Arduino Uno (1 Nos) 2. Arduino WiFi Module

3. Custom LCD Shield 4. Sensor shield

5. 12V Power Adapter (1 Nos) 6. Light Sensor


7. Buzzer 8. MQ 8 Gas Sensor

9. Temperature cum Humidity Sensor 10. RGB LED Light Strip

11. Jumper Wires 12. SIM Card for GPRS Shield


Connection Setup:

Insert the SIM Card in Arduino GPRS Shield.

Stack the Arduino GPRS Shield over Arduino Uno.

Stack the LCD Shield & Sensor Shield on the top of Arduino GPRS Shield as per the pin
markings on the top of the shield (make sure all connections are intact).

Connect the 12V DC Adapter Plug

Connecting the Sensor & Receiver:

Sensor shield pin PCB connections

12V Power Adapter plug

Gas Sensor (to pin A0)

Light Sensor(to pin A1)

Temperature Sensor( to pin A2)

Buzzer (to pin A3)

ALERT Terminal (A5)

Sensor Sheild Component


Connections
In the PCB the Sensors are
interfaced to Arduino Main board as follows:

Light Sensor
1. The terminal S of the sensor is connected to A1 terminal of Arduino*

2. The terminal - of the sensor is connected to GND terminal of Arduino*

3. The terminal + of the sensor is connected to 5V terminal of Arduino*

Buzzer

1. The terminal + of the sensor is connected to A5 terminal of Arduino*

2. The terminal - of the sensor is connected to GND terminal of Arduino*

DHT 11 Temperature and Humidity Sensor

1. The terminal Vcc of the sensor is connected to 5V terminal of Arduino*


2. The terminal GND of the sensor is connected to GND terminal of Arduino*

3. The terminal DATA of the sensor is connected to A2 terminal of Arduino*

4. The terminal NC of the sensor is left free.

MQ 8 GAS Sensor

1. The terminal Vcc of the sensor is connected to 5V terminal of Arduino*

2. The terminal AOUT of the sensor is connected to A0 terminal of Arduino*

3. The terminal GND of the sensor is connected to GND terminal of Arduino*

4. The terminal DOUT of the sensor is left free.

RGB LED STRIP CONNECTIONS(Explanation):

The RGB LED Strip is Triggered via a pulse applied from A5 teminal of Arduino (incase if any
Toxic Gas is sensed) to the base pin of TIP 120 Transistor (present onboard)
The Connections are as shown in the diagram:
VIN Terminal of Arduino (Wired
via sensor Shield)

In our Case LED


STRIP

FROM A5 TERMINAL OF ARDUINO


LCD Connections:

The connections are as shown


The LCD shield pins are marked with a Marker From pin 1 to 6

Connect the pins to arduino as shown in the below diagram

GND1
3 After making the connections as shown in this
12 diagram, connect the wires (labeled-VCC,GND)
11 from the LCD Shield to respective pins of
10 LCD Shield
9 Sensor Shield.( VCC,GND- marked on
GPRS 8 Pins
SENSOR shield)
Shield
PINs 7
6 6
5 5
4 4
3 3
2 2
1 1

Switch on the Power Supply


Switch on the GPRS Shield by pressing the key labeled as PWR for three seconds.
Make sure the antennae of the GPRS Shield is in good position.

Deploy the Program :

Deploy the Arduino Sketch AirQualityMeasurementsCode.ino(See Appendix) to


Arduino board using the Arduino IDE via an USB cable.

After Switching the system on the LCD should display Air Quality and then after few seconds
it should display sensor names and its values. Periodiclly it should display Uploading to
signify that data is being uploaded to Xively.com through the cellphone network.

Output:

If the program is correctly deployed ,


You will be able to see the live data getting updated in the graph in the xively website.
You should be able to see that the values Humidity, Light_Level ,Temperature
& Toxic Gas Level are constantly getting updated at https://xively.com/feeds/779412251
Troubleshooting:

GPRS shield is powering on, but data is not getting uploaded to the
website.or The LCD shield constantly displays Uploading

This is possibly due to the fact that the Cell Phone Data Plan has expired its MB limit. One
quick way to check this is to Recharge the SIM card data plan and Try again.
This problem also occurs when the signal strength is too low.

LCD Shield shows Uploading but data is not getting


uploaded

Make sure the API key for feed upload is correct by cross checking with the xively site
for our Air Quality Measurements Channel .The default program attached has the right
API Key in it (See the comments of the code). In future if any changes made in the
channel in the xively site, it will bring changes to the API key and the key has to updated
in the program.

No SMS is getting Delivered

This might be due to the fact that the SMS limit is exceeded or the Programmed Mobile
Number is wrong. Double check the mobile number (see comments in the code) also make
sure country code is entered. International SMS transfer will again depend upon the
mobile plan adopted.

Sensor Value constantly reads Zero

This might be due to

an open connection in the Pcb wiring connections to the sensor. Check for continuity in
the Wiring (power and signal (data) terminals) to the particular sensor using a
multimeter.

Check the pins DATA, VCC , GND lines interfaced to Arduino board. A loose
connection n any of the three might be a possible reason for null data.

If sensor data is not getting updated- Switch off and Switch on the system.

LCD shield No display

Press Reset Button on Arduino and check for Ouput Air Quality If not,

Make sure LCD Shield is inserted in a proper way as shown in the previous sections

LCD Display is erratic.


This is due to the fact that one of the sensor yielded junk output. Pressing Reset button will
solve this problem. However the problem also self rectifies itself as the Software program resets
itself every time after 30 times (data upload rate).

RGB LED Strip Constantly Flashing even if there is no Toxic


Gas:

This problem is rare to occur but if it occurs, this might be due to excessive air blown on
the gas sensor (like winds or if it too close to the fan etc).

Display shows NO GPRS SHIELD

Check if GPRS Shield is properly mounted on Arduino UNO

Data dashboard Website


Code (The html file is attached in the project folder)

Below show is a snippet of the code prepared for data dashboard. For future work, change the
feed ID and the datastream Id (channel name: like Humidity or Temperature as shown in Xively)
in the respective places marked with circles as shown
Xively Feeds URL

Feed URL
http://api.xively.com/v2/feeds/779412251/datastreams/ Humidity.json?
&key=GtGuoMKJSqv2tzqGvWaITLhlEDUxrYXSixqPSmlyj-
s&datastreams= Humidity&duration=14days&interval=10800
For Future, in the above URL link change the Feed ID, datastream or channel name as
per the requirements or changes made if any.The above URL will yield the data of the particular
channel in JSON format which is used by google visualization tool for Graphical Info rendering.

If the data doesnt load after opening the website hit refresh twice to see the output.
Appendix
/* Air Quality Measurements Project

Toxic Gas Sensor -analog pin 0


Light Sensor -analog pin 1
Temperature and Humidity -analog pin 2
Buzzer -analog pin 3 */
#include <SoftwareSerial.h>
#include <String.h>
#include "DHT.h"
#include <LiquidCrystal.h>

LiquidCrystal lcd(1,2,3,4,5,6);
SoftwareSerial mySerial(7, 8);
DHT dht(16, DHT11);
float alert_level,h,t,l,g;
unsigned long lastConnectionTime = 0;
int flag;
int count;
float senval[4];
char* channel[]={"Gas_Level", "Light", "Temp(Celcius)","Humidity" };
int ch;
void setup()
{
lcd.clear();
lcd.begin(16, 2);
lcd.print("Air Quality");

delay(800);
count=0;ch=0;

mySerial.begin(19200); // the GPRS baud rate


//Serial.begin(9600); // the GPRS baud rate
delay(500);
dht.begin();
alert_level =10; // alert level percent value
alert_level= (alert_level*1024)/100; // alert level raw value
flag=0;
delay(2000);
lcd.clear();
}

void loop() {
// Read Sensor Values
h = dht.readHumidity();
t = dht.readTemperature();
l = analogRead(1);
l = l/400*100; //Light Percent
g = analogRead(0);
g = g/1024*100; //Gas Percent
lcd.clear();
lcd.setCursor(0,2);
lcd.print(channel[ch]);
lcd.print(" ");
lcd.print(senval[ch]);
lcd.print("%");
ch=ch+1;
ch=ch%4;
senval[0]=g;
senval[1]=l;
senval[2]=t;
senval[3]=h;
delay(1000);

check_toxicity();
if (flag==1)
{
alert_sms();

}
else
{
flag=0;

}
if(millis() - lastConnectionTime > 30000)
{
lcd.clear();
lcd.print("Uploading");
update_cloud(); //upload data to xively
lastConnectionTime=millis();
}
if (mySerial.available())
{
//Serial.write(mySerial.read());
}
else{
lcd.clear();
lcd.print("NO GPRS SHIELD");
}
}

void alert_sms()
{
if (flag ==1)
{
mySerial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
delay(100);
mySerial.println("AT + CMGS = \"+19176993991\"");//send sms message, be careful
need to add a country code before the cellphone number
delay(100);
mySerial.println("Toxic Gas Level!");//the content of the message
delay(100);
mySerial.println(g);//the content of the message
delay(100);
mySerial.println("%(Message from GSM Modem JONNY)");//the content of the
message
delay(100);
mySerial.println((char)26);//the ASCII code of the ctrl+z is 26
delay(100);
mySerial.println();
}
else
{}
}

void check_toxicity()
{
noTone(17);
while (analogRead(0) > alert_level && count<5)
{
flag=1;
lcd.clear();
lcd.print("Toxic Gas Alert!!");
pinMode(19,OUTPUT);
digitalWrite(19,HIGH);

for(int i=500;i<1500;i++)
{
tone(17,i);
delay(2);
}

for(int i=1500;i>500;i--)
{
tone(17,i);
delay(2);
}
noTone(17);
count=count+1;
}
digitalWrite(19,LOW);
count=0;
}

void update_cloud()
{
String humidity = "1031";//these 4 line code are imitate the real sensor data, because
the demo did't add other sensor, so using 4 string variable to replace.
String moisture = "1242";//you can replace these four variable to the real sensor data
in your project
String temperature = "30";//
String barometer = "60.56";//
//Serial.print("Sorry");
mySerial.println("AT+CGATT?");
delay(1000);

PrintResponse();

mySerial.println("AT+CSTT=\"CMNET\"");//start task and setting the APN,


delay(1000);

PrintResponse();

mySerial.println("AT+CIICR");//bring up wireless connection


delay(3000);

PrintResponse();

mySerial.println("AT+CIFSR");//get local IP adress


delay(2000);

PrintResponse();

mySerial.println("AT+CIPSPRT=0");
delay(3000);

PrintResponse();

mySerial.println("AT+CIPSTART=\"tcp\",\"api.xively.com\",\"8081\"");//start up the
connection
delay(2000);

PrintResponse();

mySerial.println("AT+CIPSEND");//begin send data to remote server


delay(4000);
PrintResponse();
mySerial.print("{\"method\": \"put\",\"resource\": \"/feeds/779412251/\",\"params\"");//
here is the feed you apply from pachube
delay(500);
PrintResponse();
mySerial.print(": {},\"headers\": {\"X-ApiKey\":");//in here, you should replace your
pachubeapikey
delay(500);
PrintResponse();
mySerial.print(" \"9yRUVFhnGcYaW3x6rRPWR8h");//pachubeapikey
delay(500);
mySerial.print("VByQ5UWItMMnYJPur6WavAqDG");//pachubeapikey
delay(500);

PrintResponse();
mySerial.print("\"},\"body\":");
delay(500);
PrintResponse();
mySerial.print(" {\"version\": \"1.0.0\",\"datastreams\": ");
delay(500);
PrintResponse();
/* mySerial.println("[{\"id\": \"01\",\"value\": \"" + barometer + "\"},");
delay(500);
PrintResponse();
mySerial.println("{\"id\": \"02\",\"current_value\": \"" + humidity + "\"},");
delay(500);
PrintResponse();
mySerial.println("{\"id\": \"03\",\"current_value\": \"" + moisture + "\"},");
delay(500);
PrintResponse();
mySerial.println("{\"id\": \"04\",\"current_value\": \"" + temperature + "\"}]}}");
*/
//
mySerial.print("[{\"id\": \"Humidity\",\"current_value\": \"");
mySerial.print(h);
mySerial.print("\"},");
mySerial.println("");
delay(500);
PrintResponse();
mySerial.print("{\"id\": \"Temperature\",\"current_value\": \"");
mySerial.print(t);
mySerial.print("\"},");
mySerial.println("");
delay(500);
PrintResponse();
mySerial.print("{\"id\": \"Light_Level\",\"current_value\": \"");
mySerial.print(l);
mySerial.print("\"},");
mySerial.println("");
delay(500);
PrintResponse();
mySerial.print("{\"id\": \"Toxic_Gas_Level\",\"current_value\": \"");
mySerial.print(g);
mySerial.print("\"}]}}");
mySerial.println("");
delay(500);
PrintResponse();

mySerial.println((char)26);//sending
delay(5000);//waitting for reply, important! the time is base on the condition of internet
mySerial.println();

PrintResponse();
delay(3000);
mySerial.println("AT+CIPCLOSE");//close the connection
delay(100);
PrintResponse();
}

void PrintResponse()
{
while(mySerial.available()!=0)
{}
}

Vous aimerez peut-être aussi