This sensor is designed for comprehensive monitor over indoor air condition. It's responsive to a wide scope of harmful gases, as carbon monixide, alcohol, acetone, thinner, formaldehyde and so on. Due to the measuring mechanism, this sensor can not output specific data to describe target gases' concentrations quantitatively. But it's still competent enough to be used in applications that require only qualitative results, like auto refresher sprayers and auto air cycling systems.

Dependencies:   Grove_Air_Quality_Sensor_Library mbed

Fork of Seeed_Grove_Air_Quality_Sensor_Example by Austin Blackstone

Files at this revision

API Documentation at this revision

Comitter:
mbedAustin
Date:
Fri Sep 05 19:17:20 2014 +0000
Parent:
0:2dbce8e35862
Commit message:
Added interrupt driven library and made example more robust

Changed in this revision

Grove_Air_Quality_Sensor_Library.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Grove_Air_Quality_Sensor_Library.lib	Fri Sep 05 19:17:20 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbedAustin/code/Grove_Air_Quality_Sensor_Library/#885417624ec2
--- a/main.cpp	Fri Sep 05 03:39:31 2014 +0000
+++ b/main.cpp	Fri Sep 05 19:17:20 2014 +0000
@@ -1,12 +1,34 @@
-#include "mbed.h"
+
+#include"mbed.h"
+#include"Air_Quality.h"
+AirQuality airqualitysensor;
+int current_quality = -1;
+PinName analogPin = A0;
 
-AnalogIn sensor(A0);
+// Interrupt Handler
+void AirQualityInterrupt()
+{
+    AnalogIn sensor(analogPin);
+    airqualitysensor.last_vol = airqualitysensor.first_vol;
+    airqualitysensor.first_vol = sensor.read()*1000;
+    airqualitysensor.timer_index = 1;
+}
 
-int main() {
-    float sensorValue;
-    while (true) {
-        sensorValue = sensor.read();
-        printf("\r Air Quality score = %3.2f",100 - (sensorValue*100));
-        wait(5);
+// Main loop
+int main()
+{
+    airqualitysensor.init(analogPin, AirQualityInterrupt);
+    while(1) {
+        current_quality=airqualitysensor.slope();
+        if (current_quality >= 0) { // if a valid data returned.
+            if (current_quality == 0)
+                printf("High pollution! Force signal active\n\r");
+            else if (current_quality == 1)
+                printf("High pollution!\n\r");
+            else if (current_quality == 2)
+                printf("Low pollution!\n\r");
+            else if (current_quality == 3)
+                printf("Fresh air\n\r");
+        }
     }
 }