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)”
@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:
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.