I’m working with Grove - Multichannel Gas Sensor using Photon particle. I am using the code below. The system works intermittently ie come online and go offline in periods of approximately 20 seconds. Due to this failure, the readings are never totaly complete. Some gas readings are not refreshed. In addition, because of the intermittent connection, it is difficult to redo the flash when necessary. It seems to be a bug in the code. I have already tested with 3 different units in two environments with different internet connections. The behavior is always the same. Some expert could check this code please …
Thanks for any help,
Cesar
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>
// This #include statement was automatically added by the Particle IDE.
#include "MutichannelGasSensor.h"
// Read Data from Grove - Multichannel Gas Sensor
#include <Wire.h>
#include "MutichannelGasSensor.h"
char eventinfo[64];
char auth[] = "";
unsigned int ms;
int publishdelay = 60 * 1000;
// Publish CO, Humidity, Dew Point
void PublishMutichannelGasSensorInfo(){
float c = gas.measure_CO();
float d = gas.measure_H2();
float e = gas.measure_NH3();
float f = gas.measure_NO2();
float g = gas.measure_C3H8();
float h = gas.measure_C4H10();
float i = gas.measure_CH4();
float j = gas.measure_C2H5OH();
sprintf(eventinfo,"CO=%.2f|ppm",c);
Publish(eventinfo);
sprintf(eventinfo,"H2=%.2f|ppm",d);
Publish(eventinfo);
sprintf(eventinfo,"NH3=%.2f|ppm",e);
Publish(eventinfo);
sprintf(eventinfo,"NO2=%.2f|ppm",f);
Publish(eventinfo);
sprintf(eventinfo,"C3H8=%.2f|ppm",g);
Publish(eventinfo);
sprintf(eventinfo,"C4H10=%.2f|ppm",h);
Publish(eventinfo);
sprintf(eventinfo,"CH4=%.2f|ppm",i);
Publish(eventinfo);
sprintf(eventinfo,"C2H5OH=%.2f|ppm",j);
Blynk.virtualWrite(V11, c);
Blynk.virtualWrite(V12, d);
Blynk.virtualWrite(V13, e);
Blynk.virtualWrite(V14, f);
Blynk.virtualWrite(V15, g);
Blynk.virtualWrite(V16, h);
Blynk.virtualWrite(V17, i);
Blynk.virtualWrite(V18, j);
}
// Publush event
void Publish(char* szEventInfo){
Spark.publish("Gas Sensor", szEventInfo);
}
void InitializeMutichannelGasSensor(){
unsigned char id;
gas.begin();
gas.powerOn();
}
void InitializeApplication(){
Serial.begin(9600);
pinMode(D7, OUTPUT);
}
void setup() {
InitializeApplication();
Serial.println("Initializing sensors...");
InitializeMutichannelGasSensor();
Blynk.begin(auth);
}
void loop() {
Blynk.run();
PublishMutichannelGasSensorInfo();
delay(200);
}