Quantcast
Channel: Seeedstudio Forum
Viewing all articles
Browse latest Browse all 6612

Grove - Air Quality Sensor not supported Leo and Yun [Fixed]

$
0
0
Hi Seeed,

The library provided with the Grove Air Quality Sensor uses times that are not available on the Leonardo or Yun. Can you please advise me how to convert this library to work with these two cards, or point me to a better one?

Your example code gives these errors:

Code:/..http://www.seeedstudio.com/forum/Source/Arduino 1.5.6-rc2/libraries/AirQuality_Sensor/AirQuality.cpp: In member function 'void AirQuality::init(int)':
/..http://www.seeedstudio.com/forum/Source/Arduino 1.5.6-rc2/libraries/AirQuality_Sensor/AirQuality.cpp:80: error: 'TCCR2A' was not declared in this scope
/..http://www.seeedstudio.com/forum/Source/Arduino 1.5.6-rc2/libraries/AirQuality_Sensor/AirQuality.cpp:81: error: 'TCCR2B' was not declared in this scope


Here is the latest example code as of 21 February 2013:
Code:/*
  AirQuality Demo V1.0.
  connect to A1 to start testing. it will needs about 20s to start
* By: http://www.seeedstudio.com
*/
#include"AirQuality.h"
#include"Arduino.h"
AirQuality airqualitysensor;
int current_quality =-1;
void setup()
{
    Serial.begin(9600);
    airqualitysensor.init(14);
}
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++;
   }
}


Statistics : Posted by rolf.hunt • on Fri Mar 07, 2014 10:09 am • Replies 2 • Views 385

Viewing all articles
Browse latest Browse all 6612

Trending Articles