Spark core trouble connecting to computer

Hi,
I’ve got two sparks and currently one of them isn’t connecting to the computer correctly. One seems to be working fine but I noticed when testing new code that one of the core’s wasn’t updating when it flashed. the RGB LED went magenta as usual and nothing out of the ordinary appeared on the web IDE. Upon noticing the problem I decided to factory reset the spark that was giving me the problem. the same thing happened with the flashing and I can now put no code onto one of my cores. Also worth noting is that it doesn’t appear on my device manager when it’s connected to the cloud. When I master reset it, and it returns to listening mode it appears on the device manager again. Then when I connect it to my network it dissapears from the manager. If I leave it plugged in it seems to be connected to the cloud as usual and as afformentioned when I flash the core I do get the magenta lights appearing on the core. I’ve tried swapping cables and usb ports as well as flashing different code onto it.

P.S. Just master reset the core again then didn’t flash any code just pressed the reset button and again it couldn’t be found on the device manager.

Thanks for any help

1 Like

@OddieCAT, the Spark core unlike an Arduino does not appear as a COM port by default.

There are 2 cases that this occurs:

1.) Listening mode (blinking blue)

2.) You use Serial.begin() in your code

The other case will be DFU mode (blinking yellow)

Hope this helps :wink:

1 Like

Well I didn’t know that but that’s because I’ve always had Serial.begin() in my code. I did however, just check and I do have Serial.begin() in my code yet it still wont connect via serial.

You might want to try reflashing the code again just to be sure? :wink:

Seems to be back to normal now but there was definately problems flashing earlier. out of curiosity, how long do your sparks take to flash? Also is there a timeout if it takes too long? Thanks for your help.

1 Like

I guess there’s no time-out and my flashes are between 1-2 minutes i think… :wink:

Ok, so mines slow but not unreasonably slow. Thanks again.

1 Like

Bump. It's happening again. Here's my error log:

05/2/15 13:43 A long run of nothing wrong but we’re back to the no flashing problem. I’ve run some HTTP Client code on both of my cores but neither will flash it correctly. I’ve master reset both to no avail. Trying master reset again now. Uno woudn’t let me connect to serial. Trying a re-flash and run as administrator. I’ll then mess with the SparkDev IDE to see if the web IDE is the problem. Nope, SparkDev working no better.

Tried 3/4 different sets of known working code on two cores. Internet connection maybe?

@OddieCAT,

maybe sharing your code here for the community folks to review would help a lot :wink:

Here’s an example but I’ve master reset and used other code than this several times as well. I can provide that if necissary

#include "application.h"
    #include "HttpClient/HttpClient.h"
    
    /**
* Declaring the variables.
*/
unsigned int nextTime = 0;    // Next time to contact the server
HttpClient http;

// Headers currently need to be set at init, useful for API keys etc.
http_header_t headers[] = {
    //  { "Content-Type", "application/json" },
    //  { "Accept" , "application/json" },
    { "Accept" , "*/*"},
    { NULL, NULL } // NOTE: Always terminate headers will NULL
};

http_request_t request;
http_response_t response;

void setup() {
    Serial.begin(9600);
    Serial.println("Wales");
}

void loop() {
    if (nextTime > millis()) {
        return;
    }

    Serial.println();
    Serial.println("Application>\tStart of Loop.");
       Serial.println("Wales");
    // Request path and body can be set at runtime or at setup.
    request.ip = {192,168,1,xxx,xxx};
    request.port = 80;
    request.path = "/emoncms/input/post.json?json={power:456}&apikey=3b172c8064620d9de6dcb4550b49xxxx";

    // The library also supports sending a body with your request:
    //request.body = "{\"key\":\"value\"}";

    // Get request
    http.get(request, response, headers);
    Serial.print("Application>\tResponse status: ");
    Serial.println(response.status);

    Serial.print("Application>\tHTTP Response Body: ");
    Serial.println(response.body);

    nextTime = millis() + 10000;
}

It’s happened again. Had the core working for one day then it’s been broken the last 2 days. Very frustrating being unable to test my code. Code is still the code posted above with small variable changes.

It may be that your millis( ) timer is overflowing your int... maybe.

Try this:

#include "application.h"
    #include "HttpClient/HttpClient.h"
    
    /**
* Declaring the variables.
*/
unsigned long nextTime = 0;    // Next time to contact the server
HttpClient http;

// Headers currently need to be set at init, useful for API keys etc.
http_header_t headers[] = {
    //  { "Content-Type", "application/json" },
    //  { "Accept" , "application/json" },
    { "Accept" , "*/*"},
    { NULL, NULL } // NOTE: Always terminate headers will NULL
};

http_request_t request;
http_response_t response;

void setup() {
    Serial.begin(9600);
    Serial.println("Wales");
}

void loop() 
{
    if (millis() - nextTime > 10000UL)
  {
    Serial.println();
    Serial.println("Application>\tStart of Loop.");
       Serial.println("Wales");
    // Request path and body can be set at runtime or at setup.
    request.ip = {192,168,1,xxx,xxx};
    request.port = 80;
    request.path = "/emoncms/input/post.json?json={power:456}&apikey=3b172c8064620d9de6dcb4550b49xxxx";

    // The library also supports sending a body with your request:
    //request.body = "{\"key\":\"value\"}";

    // Get request
    http.get(request, response, headers);
    Serial.print("Application>\tResponse status: ");
    Serial.println(response.status);

    Serial.print("Application>\tHTTP Response Body: ");
    Serial.println(response.body);

    nextTime = millis();
  }
}

Still nothing but that’s probably an improvement to combat an error I haven’t come across yet! I’m pretty convinced it’s either my internet or something wrong with the core because I can’t even flash the “blink an LED” after a master reset!

try my edit (once you can load it)

I hadn’t really noticed how you were delaying the call.

Yeah I will.

Update:
Tried the core on a different internet connection and it worked. Must be the internet connection here as we run on a satallite link. Anyone have any idea’s on the timeout for flashing or a way to work around this? Been succesfully flashing my core for 3 months so I don’t know why these issues are coming up now.

1 Like