Dropping the connection to spark cloud

I reflashed the f/w last night with unchanged code (see below) but told my linux box to stop polling for information every minute. I also did NOT have a serial console open. My core has been running for almost 12 hours without issue. I just opened up a serial console and will see if that lasts for over 2 hours (my previous record). If so, then I’ll re-enable my cron job and start polling for values and see how that goes.

It may be that requesting info from the core every minute increases the likelihood of a network issue. However, I thought I read somewhere that spark was pinging something every 15 seconds or so. I’ll report back with what I find. I’m hoping this is helpful.

@Dave - You mentioned “bug where the core doesn’t always reconnect on its own”. Just to be clear, once I get the blue-flash-of-death, my core never reconnects without a physical reset.

Dave O

 int uptime, data;

const int LED=D7;
const int ANALOG=D1;

const unsigned long DELAY_TIME = 10000;   // number of milliseconds 

unsigned long delayTimer = 0;

void setup() {

    Spark.variable("uptime", &uptime, INT);
    Spark.variable("data", &data, INT);
    
    pinMode(LED, OUTPUT);
    Serial.begin(9600);

    delayTimer = millis ();
}

void loop(void) {
    
    if (millis () - delayTimer > DELAY_TIME)    // Run this function every DELAY_TIME milliseconds
    {
        // Turn on the LED when reading temperature - should be every DELAY_TIME
        digitalWrite(LED, HIGH);
        
        delay (2000);                           // Tossing this in as a "reasonable" delay that a temperature reading might encounter
        
        digitalWrite(LED, LOW);
  
        delayTimer = millis ();                 // update delayTime to new value of millis ()
        uptime     = delayTimer / 1000;         // keep track of how many *seconds* the spark has been running.
        
        Serial.print   ("uptime is ");
        Serial.print   (uptime);
        Serial.print   (" seconds, ~");
        Serial.print   (uptime / 60);
        Serial.print   (" minutes   ");
        
        
        data = analogRead(ANALOG);
        
        Serial.print   ("Data from ANALOG = ");
        Serial.println (data);
    }
    
}
1 Like