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


#1

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 !


#2

Where is this AirQuality library from?

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


#3

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


#4

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>


#5

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


#6

How can I get rid of this ?


#7

@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:


#8

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 ?


#9

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


#10

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.