Flashing from web IDE results in "Core Not Found"

I’m having trouble getting TCPClient to make POST or GET requests from my Core. I’ve been struggling to find any basic examples, and the one example that I found seems to cause my Core to get lost as soon as I try to refactor the code for my own use.

  1. Core “breathing cyan”
  2. Hack together some code
  3. Code Verify’s okay.
  4. Click Flash…
  5. Compiling code…
  6. The request seems to take longer than usual. Please be patient…
  7. Core starts flashing cyan
  8. Core goes back to “breathing cyan”
  9. Error: Core not found. Please check that it is online.

I have a 1 second delay in the loop, nothing crazy. A factory reset brought it back to life but I am now back to the same place where it’s failing to find my Core when I make the smallest tweak to the code.

I can’t tell if this is code related, IDE, cloud, network, or anything else. The inability to flash does seem rather arbitrary.

Any help would be appreciated.

This would be the code I’m working with. It’s basic, just trying to get some strings from the Core to my own web service.

TCPClient client;

byte server[]  = { 50, 87, 146, 166 };

void setup()
{
    Serial.begin(9600);
}

void loop()
{
    
    if ( client.connect(server, 80) ) {
        Serial.println("connected");    

        String data = "what=looping";

        client.print("GET /log/spark1?what=looping HTTP/1.1\n");
        client.print("Host: spark.quickcodr.com\n");
        client.print("Connection: close\n");
        client.print("Content-Length: ");
        client.print(data.length());
        client.print("\n\n");
        client.print(data);

        delay(1000);
        client.flush();
        client.stop();
    }
    
}

Hey @crstffr,

Thanks for posting your code! loop is called many thousands of times a second, and the core can only open a few sockets at a time. For starters, try something more like…

TCPClient client;

byte server[]  = { 50, 87, 146, 166 };

void setup()
{
    Serial.begin(9600);

    if ( client.connect(server, 80) ) {
        Serial.println("connected");    

        String data = "what=looping";

        client.print("GET /log/spark1?what=looping HTTP/1.1\n");
        client.print("Host: spark.quickcodr.com\n");
        client.print("Connection: close\n");
        client.print("Content-Length: ");
        client.print(data.length());
        client.print("\n\n");
        client.print(data);

        delay(1000);
        client.flush();
        client.stop();
}

void loop()
{
}

Just for starters. You may need to factory reset your core, if it’s not able to stay online long enough to be re-flashed. SaraJo also has a great example of tweeting from the core here: https://github.com/SaraJo/spark-tweets

Thanks,
David

1 Like

Thanks Dave for your response and link to the Arduino Tweet code. I’ll adjust what I have accordingly.

It wasn’t my intention to have the TCP requests being made in the loop, but I am having a difficult time getting any changes to that code to flash properly.

I did factory reset once yesterday and started from scratch with a new “app” in the IDE. But then I got to about the same place in the code as above and then I’d get the “Core not found” message again.

So I’m still not sure if it really is code related, network issues, the core itself, or what have you. My adventure continues… :smile:

Hi @crstffr,

Our cloud and core firmware updates today include some major reliability improvements during flashing and while staying online. We’ll post an update when those get rolled out and hopefully that will make things a bit smoother. :smile:

Thanks,
David

Wonderful, I look forward to it!

1 Like

Hi. Not sure if this is exactly related to this thread -
I got the IDE to list my core once, but no longer does.
The error at the bottom says “No Cores Associated With Your Account”.
I have the ID. I am connected to Wifi.
Any thoughts?

Thanks.

Hey @Roger,

Sorry if this is silly advice, but sometimes it’s nice to have someone else run through some quick checks.

1.) Make sure you’re logged in using the same email / pass as you were before. (The apps and website make it very easy to create a new account, and it’s possible you’re using a different account).

2.) Click on ‘cores’ on the spark.io/build site, do you see the little ‘right arrows’ anywhere in that column? It’s possible you renamed your core, or your core name is blank, and it’s hiding.

If that doesn’t help, could you grab your core id over serial (make sure it’s the same as what you have), and email that to us from the email account you’re using as your username to hello@spark.io, we can check and see what’s going on behind the scenes.

Thanks!
David