Turning PGIO off while Photon is connecting to WiFi

Hello All,
I have 4 PWM outputs that turn on while Photon is connecting to the WiFi. This is an undesirable effect that I am trying to avoid.
Any help would be highly appriciated

One way to handle this is to use SYSTEM_THREAD(ENABLED) and check WiFi.ready() in loop().

If not ready and your PWM Is on, turn it off.

If ready and your PWM is off, turn it on.

Another way is to use the network_status system event with System.on().

Thanks, rickkas7
Sorry, sir, I am not so good at software
Am I putting WiFi.ready() in my main loop()?

Hi,
you can try something like this:

#define Your_Pin A1

SYSTEM_THREAD(ENABLED)
void setup() {

pinMode(Your_Pin, OUTPUT);     // sets the pin as output
analogWrite(Your_Pin, 0);

}

void loop() {

if(!WiFi.ready()){
   analogWrite(Your_Pin, 0);
  }else{
    //YOUR EXISTING LOOP CODE GOES HERE  
  }
}

Thanks, Arek I will try it

Arek.
Sir, you are a gentleman and a scholar.
You saved me a lot of time.
It is working great. When the power is applied or when the rest is applied
PWM outputs are turned on for about a second. It is much better than what I had before.
Thanks

1 Like

Thanks, @rickkas7, @dreamER You saved me a lot of time