Air quality sensor Groove (version 1.3)

#1

Hi i need help setup groove air quality sensor value to Cayenne, Currently using arduino yun, and grove base shield to program the sensor value . Need help with the coding part keep getting error or the values are not right.

0 Likes

#2

need to provide more details: what is the error, the code you are using and any docs link to it.

0 Likes

#3

This is the program code that i did

#define CAYENNE_PRINT Serial
#include <CayenneMQTTYun.h> //MQTT Arduino Yun Library


//Username,password,clientID from Cayenne webpage
//Allow Arduino to communicate with Cayenne
char username[] = "xxxxxxxxxxxxxxxxxxxxxxx";
char password[] = "xxxxxxxxxxxxxxxxxxxxxxx";
char clientID[] = "xxxxxxxxxxxxxxxxxxxxxxxx";

 #include "Air_Quality_Sensor.h"

AirQualitySensor sensor(A0);

void setup(void) {
  Serial.begin(115200);
  while (!Serial);

  Serial.println("Waiting sensor to init...");
  delay(20000);

  if (sensor.init()) {
    Serial.println("Sensor ready.");
  }
  else {
    Serial.println("Sensor ERROR!");
  }
Cayenne.begin(username, password, clientID);  //begin communication between Arduino and Cayenne
}
void loop() {
Cayenne.loop();

 int quality = sensor.slope();

  Serial.print("Sensor value: ");
  Serial.println(sensor.getValue());

  if (quality == AirQualitySensor::FORCE_SIGNAL) {
    Serial.println("High pollution! Force signal active.");
  }
  else if (quality == AirQualitySensor::HIGH_POLLUTION) {
    Serial.println("High pollution!");
  }
  else if (quality == AirQualitySensor::LOW_POLLUTION) {
    Serial.println("Low pollution!");
  }
  else if (quality == AirQualitySensor::FRESH_AIR) {
    Serial.println("Fresh air.");
  }

//VirtualWrite allow you to display the data collected to the Cayenne Cloud
  // and display it on your mobile and computer
    Cayenne.virtualWrite(1,**sensor**, "Air", "ppm"); // This part is i am stuck with if i use quality get 3 for value if use sensor get exit status 1
    delay (2000);
}
0 Likes

#4

i guess this should help you understand the code properly why you are getting value 3 when used quality http://wiki.seeedstudio.com/Grove-Air_Quality_Sensor_v1.3/
the error when using sensor is because you have not initialized it in the code and you are using it. replace it with sensor.getValue() and it should solve your issue.

2 Likes

#5

Ohh thanks it works

2 Likes