Core does not reconnect to WiFi after flash from cloud (diode blinking green)

I have bumped in to an issue with my core recently. Each time I re flash the core from the web IDE everything runs smoothly until the core restarts. It then cant reconnect to the WiFi and just keeps blinking green searching for the network. If I pull the power to the core and reconnects it, the core connects to the network instantly again and works fine whit the recently flashed code. Then when trying to flash again, the same thing happens.

Have tried to hook it up to a new powersupply, same behavior.
Tried different distances to the router, same behavior on all distances :.
Tried other code (the blink a led example), same behavior.

Any tips on what could be causing this and how to debug it further?

Did you happen to perform the deep update recently? :wink:

Sure did, but that should increase connectivity :wink: not the opposite. I hoped :slight_smile:

Yup, just to be sure. :smiley:

If you can, do share your code with us so that we can spot blocking-codes if any :wink:

Sure, here i a small code that I’m testing now. But as mentioned it is the same whatever I have tried with it so far. Tried older code that worked fine before and the included blink LED example.

// This #include statement was automatically added by the Spark IDE.
#include "OneWire/OneWire.h"

// This #include statement was automatically added by the Spark IDE.
#include "spark-dallas-temperature/spark-dallas-temperature.h"

OneWire onewire = OneWire(D3);
DallasTemperature sensors(&onewire);
int BastuTemp;
int PoolTemp;

void setup() {
    Spark.variable("BastuTemp", &BastuTemp, INT);
    Spark.variable("PoolTemp", &PoolTemp, INT);

void loop() {
    BastuTemp  = (int) (sensors.getTempCByIndex(0));
    PoolTemp = (int) (sensors.getTempCByIndex(1));


Ok so the first obvious thing is delay (10000) which will cause a time-out of the connection to the spark cloud.

Try something like 3000 and see how it goes?

Have played around with several values down to 200, same behavior. And it is not disconnecting while it is running, it’s only when flashing new firmware.

What I will do is use the firmware with delay (200) and press the RST button on the core and see if the same behavior happens.

@kennethlimcp, the delay() function will call the background task SPARK_WLAN_Loop() for long delays so this is not where the issue is. However, using delay() is never my first choice. Instead using a millis() based timer is truly non blocking and better form:

Before setup() add:

unsigned long sampleTimer;
#define sampleTime 10000

At the end of setup(), add:

  sampleTimer = millis();

Change loop as follows:

void loop() {
    if ((millis() - sampleTimer) >= sampleTime) {
       BastuTemp  = (int) (sensors.getTempCByIndex(0));
       PoolTemp = (int) (sensors.getTempCByIndex(1));
       sampleTimer = millis();


1 Like

Thanks for the tip @peekay123. Will try to use it when I go into the next step of this application where non blocking can be more important for the overall functionality.

I did some testing yesterday with different times etc but did not solve the problem. So I then, since I was out of clues, triggered a new deep update trough dfu mode on the core. And after that it started to behave normally again running fine for hours :-).

But, since there is always a a but, we had a thunderstorm here this night and I had the core running to see that it was stable. And in the morning it was dead :-(. When I hook it up to power the main diode gives a red light and the MCU gets burning hot. So I think the lightning burned it. Giving it a new try with my second core tonight, just gonna buy a new power cord with lightning protection first…