Airqualitysensor initialised in globally but still not visible in setup or loop function

I have initialised airqualitysensor at global level

AirQuality airqualitysensor;

and then call it in setup function

void setup() {
    // Connect to ThingSpeak
    ThingSpeak.begin(client);
    airqualitysensor.init(14);
    // run the first measurement
    loop();
}

void loop() {
    
    int airquality = airqualitysensor.slope();
}

But I am getting this error:
thermometer.ino:79:0: undefined reference to "AirQuality::slope()"
thermometer.ino:64:0: undefined reference to “AirQuality::init(int)”

why please help !

Where is this AirQuality library from?

BTW, you shouldn’t call loop() from setup()

from seeedstudio website: https://github.com/SeeedDocument/Grove_Air_Quality_Sensor_v1.3/raw/master/res/AirQuality_Sensor.zip

https://www.seeedstudio.com/Grove-Air-quality-sensor-v1-3-p-2439.html

I saw another post in forum that had similar talk b

so I downloaded the pwm_lvc.h and pwm_lvc.cpp from above GitHub resource

after I included those now I am getting this error

pwm_lvc.h:4:20: avr/io.h: No such file or directory
because io is included in pwm_lvc.h
#include <avr/io.h>

Particle devices don’t use AVR chips hence the library will need some porting.

How can I get rid of this ?

@seaurchin, by saying the library needs to be “ported”, @ScruffR is talking about having to adjust the code to use a 12-bit value instead of 10-bit values used by Arduino. Furthermore, the library uses a hardware timer and ISR which could be converted to a Particle Software Timer. Finally, I believe the library is written assuming 5v power to the sensor, not 3.3v. All this to say that plenty of work needs to be done to adapt the library for Particle devices.

You might want to consider newer sensors like these:

1 Like

Can I have some logical explanation for both the sensor you listed ?

Also since I am in china , I have the chinese version of CCS811 available at very low cost !
how different would they be ?

If you want reliable gas sensing I'd stay away from th CCS811.
I've tested several of these of multiple vendors and never got satisfying results (major drift).

I think @RWB has also performed some tests and came to similar conclusions.
See here

I listed the CCS811 as an example but I agree with @ScruffR in regards to its long term stability. Everything I read indicates the SGP30 is a much better sensor overall with good stability.

1 Like