Air Quality Sensor v3 Arduino

Grove is a modulated, ready-to-use tool set.
Much like Lego, it takes a building block approach to assembling electronics.

Moderators: lily.li, violet, salmanfarisvp, jeremy882, crail.lyu969

Post Reply
risforryan
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Sat Apr 27, 2019 2:19 am

Air Quality Sensor v3 Arduino

Post by risforryan » Sat May 04, 2019 2:47 am

I'm getting an error after trying to compile my code to an Arduino Uno.

Code: Select all

sketch_may03a:4:1: error: 'AirQualitySensor' does not name a type
 AirQualitySensor sensor(A0);
 ^
I'm using the code example from this site as well as the library that was linked to it. Is there any fix?

bill.yu
Junior-7
Junior-7
Posts: 735
Joined: Mon Apr 02, 2018 11:05 am

Re: Air Quality Sensor v3 Arduino

Post by bill.yu » Mon May 06, 2019 6:47 pm

Hi there,

please use the example inside of the library. or use the below code, i will update the wiki. thanks.

Code: Select all

#include"AirQuality.h"
#include"Arduino.h"
AirQuality airqualitysensor;
int current_quality =-1;
void setup()
{
    Serial.begin(9600);
    airqualitysensor.init(A0);
}
void loop()
{
    current_quality=airqualitysensor.slope();
    if (current_quality >= 0)// if a valid data returned.
    {
        if (current_quality==0)
            Serial.println("High pollution! Force signal active");
        else if (current_quality==1)
            Serial.println("High pollution!");
        else if (current_quality==2)
            Serial.println("Low pollution!");
        else if (current_quality ==3)
            Serial.println("Fresh air");
    }
}
ISR(TIMER2_OVF_vect)
{
    if(airqualitysensor.counter==122)//set 2 seconds as a detected duty
    {
        airqualitysensor.last_vol=airqualitysensor.first_vol;
        airqualitysensor.first_vol=analogRead(A0);
        airqualitysensor.counter=0;
        airqualitysensor.timer_index=1;
        PORTB=PORTB^0x20;
    }
    else
    {
        airqualitysensor.counter++;
    }
}

risforryan
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Sat Apr 27, 2019 2:19 am

Re: Air Quality Sensor v3 Arduino

Post by risforryan » Mon May 06, 2019 8:55 pm

Thank you!

Post Reply