New feature: control your connection!

i think system mode semi auto is ok

call WiFi.on(); to make sure the cc3k is on, i think there was discussion to start with cc3k off

then clear cred’s
then set creds’s
then Wifi.connect() // this checks !WiFi.ready() itself internally

thats it, it should connect

after that you should be able to test WiFi.ready() which checks if the DHCP has issued an IP

Thanks for the answers !!!

I don't really need to manage the "process" by myself. As I just want to be able to decide when my Spark Core connects (after clearing and setting the credentiels), I actually think that the SEMI_AUTOMATIC MODE can be enough for me

When puttin WiFi.on() as you said, the Spark manages to reach the "breathing cyan" state.
But I've made what you said (WiFi.on() -> clear creds -> set creds -> WiFi.connect() -> Udp.begin(8888) ) and even if the LED is breathing cyan, I'm unable to communicate with the Spark :-/

I'm communicating by sending OSC messages over UDP (I'm used to do it, and it worked before I got into this SYSTEM_MODE / WiFi / Cloud stuff :slight_smile:

And I've also tried to go back to my usual internet box, setting the credentials via the serial connection, and connecting manually to the cloud (WiFi.on() -> WiFi.connect() -> Spark.connect() -> Udp.begin(8888) ) and it doesn't work either. It is supposed to be equivalent to my usual setup, except that I connect manually to the wifi and cloud, the LED is breathing cyan, but I'm unable to communicate with the Spark

I think the colours have all changed… well some anyways… i cant remember where i found the new ones! ill keep looking soon.

Could you connect via usb and get some debug info out? maybe some network info? SSID its connected to etc?

WiFi.setCredentials(MY_AP_SSID, MY_AP_PASSWORD, WPA2);

Im guessing you define these at the top of your code somehow? could you share those lines too?

I'm directly typing my SSID and password between quotes where i've written "MY_AP_SSID" and "MY_AP_PASSWORD" in my post

I think I had problems with my wifi network, I’ve solved it

I’m still experimenting by connecting to my usual internet access provider
i.e. with SYSTEM_MODE(SEMI_AUTOMATIC) -> WiFi.on() -> clear creds -> set creds -> WiFi.connect() -> Spark.connect() -> Udp.begin(8888)
and most of the time it doesn’t work.

when it works, the LED ends breathing cyan and I can get the WiFi.SSID() and WiFi.localIP(), and communicate with the Spark
when it doesn’t work, the LED either :

  • shows the red SOS and the Spark reboots
  • is blinking dark blue, indicating that the Spark thinks I will register credentials via a serial connection (the credentials have not been registered when the WiFi.connet() function is called). When this last case happens, I have to reset the Spark to factory settings

it seems absolutely arbitrary

there are some checks done when you call WiFi.connect that will trigger listening mode… related to the NVMEM that get written when you set the credentials. And that’s well above my pay grade!

With the red SOS what is the number of flashes between the SOS? may help the elites work it out


For the red SOS I just saw this message but no flashes in between…

But I have news about my problem : actually, if I remove the calls to WiFi.hasCredentials() and WiFi.setCredentials() I have no more problems. So my problem was clearly related to these functions, but the semi-automatic mode works

1 Like

Any updates regarding my problem?

Hey @markopraakli,

Good question! :slight_smile: I filed an issue on github today before its forgotten and @mdma has fixed it already.

The fix not available on the Web IDE though.

Hello all !

In addition to the WiFi.hasCredentials() / WiFi.setCredentials() problems, I’m still unable to communicate with my Spark when it’s not connected to the Cloud (= when I remove the Spark.connect() call), even with my usual internet box at home…

So at least two features of the connection control are not working. Should I create two issues on github about that ?

Just to be sure, if remove Spark.connect() you’ll have to add Wifi.connect() instead. If you can share your source that will help others reproduce the problems.

1 Like

Yep thanks for the answer.

I was using WiFi.connect() when not using Spark.connect()

Here is my code :

I’m using this library to communicate with my Core via OSC :

I’ve downloaded the latest core-firmware and I’ve done many tests. The situation is a bit different with the new firmware, and here is a summary :

  • if I use SYSTEM_MODE(AUTOMATIC) my code is working but the Spark is connected to the cloud (as intended)

  • if I use SYSTEM_MODE(SEMI_AUTOMATIC) -> WiFi.on() -> Spark.connect() -> Udp.begin(8888) (it is upposed to be the exact same situation) the LED is breathing cyan, but I am unable to communicate with my Core via OSC

  • if I use SYSTEM_MODE(SEMI_AUTOMATIC) -> WiFi.on() -> WiFi.connect() -> Udp.begin(8888) (which is the setup I want to use), the LED is breathing green, but I am unable to communicate with my Core
    via OSC either

  • I’ve commented the few lines dealing with the credentials (first clearing, then setting the one I want to use) because it puts the Spark Core in a random state, as described earlier

Thanks to you all for your help !


Was somebody able to reproduce this bug or has an idea of how to solve this ?
(Maybe I just have to wait for new commits in the Spark Firmware ? If you @zachary or @satishgn have recommandations about that, it would be very welcome)

Thanks in advance !

I think you need both WiFi.connect() followed by Spark.connect(). At least that’s what I did in my code requiring SEMI_AUTOMATIC.

It would be surprising, since WiFi.connect() is called within the Spark.connect() function :slight_smile:

So you managed to comunicate with your Spark Core with SYSTEM_MODE(SEMI_AUTOMATIC), and by calling WiFi.on(), WiFi.connect() and Spark.connect() within the setup() function ? (i.e. by connecting manually to the cloud, but still, it’s not working for me either)

Thanks for the answer !

help me understand this:
I like to

  • to be connected to the cloud for 30 seconds after start (to give it a chance to update the spark if I need to for 30 seconds after start.)
  • then disconnect from the cloud and only use local wifi… be happy within my loop and do only local wifi traffic.

if I need an update I restart and for 30 seconds I am ok to do so.

(don’t need credentials …)



here is how I would do it…, don’t want to try it as I might not be able to connect to the cloud any more if I do it wrong…

  2. WiFi.on()
  3. WiFi.connect()
  4. spark.connect

after 30 seconds
spark.disconnect ??

@kw123: In my project I just use the standard mode. No calls to switch Wifi on or to connect are needed. In setup I have a simple loop that waits for some seconds to allow switching modes, serial commands and flashing. At the end of setup is the call to Spark.disconnect(). Further on in my loop() function I’ve added a timed check of the mode button to allow manual control of the connection status.

BTW, There’s no need to be afraid to try, as in emegency cases you can always do the factory reset to put your spark core back to original conditions.

maxint, thanks,
I have tried this: after 30 seconds do a
– spark.disconnect()
but no change in stability.

will now do a very simple program, check stability, then increase function to see where it goes wrong.

btw how do you check the mode button?


    if (sparkStillConnected){  // initialize variable to true at start
        if (millis() > 30000 ){  // == 30 seconds
            sparkStillConnected = false;  // don't do it again
            Serial.println("Loop spark . disconnect after 30 seconds");
            delay(100); // just for safety
            Spark.disconnect();  // here we say good by to spark

I am using SEMI-AUTOMATIC mode but have had to ensure I call Spark.process() regularly within my main loop.

I have used the Spark.connect() and Spark.disconnect() functions by calling them with a local TCP IP command when required but also I also use it when I automatically connect two times a day within the code:-

   else if (hours == 8 || hours == 20)            // wake up if not on backup battery
            int waitconnect = millis();
            while(!WiFi.ready() && ( millis() -waitconnect < 5000) )   //wait up to 5 seconds
                SPARK_WLAN_Loop();    // run backgound task so wifi can turn on
            if (Spark.connected() == false) 
                sparkonoff = 0;       //flag to indicate whether Spark core  was already connected
            Spark.syncTime();        // synch time twice per day
            delay(500);             // allow time to synch before disconnect
            if(sparkonoff == 0)
        	sleepflag = 1;

I based my mode-button connect/disconnect implementation on this excellent post by @bdub.

Don’t you see any change in stability when your core is disconnected (breathing green)?
In my project the difference is immense: from less than half an hour to multiple days continuous operation.

However, I experienced multiple causes for instability. An important one was this: most urls in my server perform some action and then show the index page. At first the specific order was: action; redirect. Lengthy actions (containing delays) would impact stability. This instability was improved significantly by first returning the redirect header prior to executing the action. I now suspect delays in responding to a request to increase instability.