Breathing white, no wifi in SEMI_AUTOMATIC mode

Hello, Why my core doesn’t connect to the Wifi if Im using this example?
Is goes to breathing white light and nothing else.

// Insert firearm metaphor here
SYSTEM_MODE(SEMI_AUTOMATIC);

void setup() {
  pinMode(D7, OUTPUT);
  attachInterrupt(D0, connect, FALLING);
}

void loop() {
  digitalWrite(D7, HIGH);
  delay(500);
  digitalWrite(D7, LOW);
  delay(500);
}

void connect() {
  if (Particle.connected() == false) {
    Particle.connect();
  }
}

(I edited your post to put three ``` before and after the code block for formatting)

Is it possible that you are not triggering the interrupt for it to connect? Can you change D7 to turn on or off in your connect() function to make sure it’s triggering properly?

Yes it worked your way. Why do you think it didn’t work using D0?
Thank You

D0 is shared with A5 and the SETUP BUTTON for EXTI interrupts… so this is not a good pin to use for attachInterrupt() https://docs.particle.io/reference/firmware/photon/#attachinterrupt- :wink:

1 Like

Thank You! all clear

1 Like

Is there a way to start the loop no matter if there is no wifi without using any interrupt? For example when the Core is powered on to start the loop while the core is searching for wifi?
something like this.

#include "elapsedMillis/elapsedMillis.h"

elapsedMillis event1;


SYSTEM_MODE(SEMI_AUTOMATIC);

void setup() 
{
  pinMode(D7, OUTPUT);
  WiFi.connect();
}


void loop() 
  {
  digitalWrite(D7, HIGH);
  delay(500);
  digitalWrite(D7, LOW);
  delay(500);
  
  
    if (event1 > 20000)  
      

    if (WiFi.ready())
    
    {
// Do this
    }
    else
    {
 //do something else
    }
    }

Yes sure, just try it :wink:

Can’t harm :sunglasses:

You could also try the shiny new system threads :slight_smile:

I tried that code, but it won’t start the loop until it connects to the wifi.

https://docs.particle.io/reference/firmware/photon/#system-thread
Have a look.

@Moors7, I believe @josefdz is using a Core, not a Photon. System threads don’t work on a Core.

Right, must've missed that :see_no_evil: This might be interesting though:

Thank You for your replies. Yes I had a Core, Tried the Photon and It works. Yay…
Thank You Again…