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()?

you can try something like this:

#define Your_Pin A1

void setup() {

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


void loop() {

   analogWrite(Your_Pin, 0);

Thanks, Arek I will try it

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.

1 Like

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