Photon with intermittent connection

Dear all,
After some time after my last post to ScruffR, I was able to get my Multichannel Gas Sensor to work correctly. I noticed that my Photon unit had a crack close to the connector and for this reason it was not possible to read Particle Serial Monitor. I purchased a new unit and introduced new tests, this time looking at the results of Particle serial Monitor. The results were as negative as previously obtained by Console particle or by Blynk. In short, the problems of intermittent connection continued.
Some time later, I found a code made by the manufacturer a little different from mine but that worked very well. I was also advised to remove the resistors at inputs D0 and D1. With these changes the system worked perfectly well.
I need to make it clear that I do not know why my old code did not work as well as this one. I just know it now works perfectly well.
Probably the Photon experts can delve deeper into this issue. Anyway, I am very grateful to ScruffR and others for their dedication to the effort to better understand the problem.
The new code is attached. I used the original libraries without modifications.

#include <blynk.h>
#include "MutichannelGasSensor.h"
SYSTEM_THREAD(ENABLED)
       char eventinfo[64];
       char auth[] = "...........";
       unsigned int ms;
       int publishdelay = 60 * 1000;

BlynkTimer timer; // Create a Timer object called "timer"!
int times;

void ReadSensor(){
    float c;
    c = gas.measure_NH3();
    Serial.print("The concentration of NH3 is ");
    Blynk.virtualWrite(V6,c);

    
    if(c>=0) Serial.print(c);
    else Serial.print("invalid");
    Serial.println(" ppm");
    c = gas.measure_CO();
    Serial.print("The concentration of CO is ");
     Blynk.virtualWrite(V4,c);
    
    if(c>=0) Serial.print(c);
    else Serial.print("invalid");
    Serial.println(" ppm");
    c = gas.measure_NO2();
    Serial.print("The concentration of NO2 is ");
     Blynk.virtualWrite(V7,c);
    
    if(c>=0) Serial.print(c);
    else Serial.print("invalid");
    Serial.println(" ppm");
    c = gas.measure_C3H8();
    Serial.print("The concentration of C3H8 is ");
     Blynk.virtualWrite(V8,c);
    
    if(c>=0) Serial.print(c);
    else Serial.print("invalid");
    Serial.println(" ppm");
    c = gas.measure_C4H10();
    Serial.print("The concentration of C4H10 is ");
     Blynk.virtualWrite(V9,c);
    
    if(c>=0) Serial.print(c);
    else Serial.print("invalid");
    Serial.println(" ppm");
    c = gas.measure_CH4();
    Serial.print("The concentration of CH4 is ");
     Blynk.virtualWrite(V10,c);
    
    if(c>=0) Serial.print(c);
    else Serial.print("invalid");
    Serial.println(" ppm");
    c = gas.measure_H2();
    Serial.print("The concentration of H2 is ");
     Blynk.virtualWrite(V5,c);
    
    
    if(c>=0) Serial.print(c);
    else Serial.print("invalid");
    Serial.println(" ppm");
    c = gas.measure_C2H5OH();
    Serial.print("The concentration of C2H5OH is ");
     Blynk.virtualWrite(V19,c);
    
    
    if(c>=0) Serial.print(c);
    else Serial.print("invalid");
    Serial.println(" ppm");
    delay(1000);
}

void setup() {
    Serial.begin(9600); // start serial for output
     Blynk.begin(auth);
    Serial.println("power on!");
    gas.begin(0x04);//the default I2C address of the slave is 0x04
    gas.powerOn();
    Serial.print("Firmware Version = ");
    Serial.println(gas.getVersion());
    timer.setInterval(1000L,ReadSensor);
}

 void loop()
{
    Blynk.run();
    timer.run(); // SimpleTimer is working
}
1 Like

Just to know, the link for that code is:

Cesar

Hello Scruff, can you please provide me the lib for the multi chanel fas sensor? thanks in advance.

Sorry, after helping @cesar, I deleted the project since and hence all shared revisions of that project went out of scope too :pensive: