Photon boot sequence and speed

For my application it is important to get a PWM active as soon as possible after power on.

Some measurement we just did puts the time between power on and PWM active at around 2.2 seconds. That’s a bit long. Is there a way of speeding this up?

Is there some documentation that describes just what exactly the photon does upon power-on? For example, does it attempt to connect to WiFi before running application code? (We didn’t attempt to measure that)

1 Like

Some of the info you want is in the docs under System Modes. Did you test in Automatic mode (that’s the default)? In Semi-Automatic and Manual modes, the application software runs immediately before the device connects to the cloud.

By default, the Photon waits for a cloud connection before it runs any user code.

This is described here:
https://docs.particle.io/reference/firmware/photon/#system-modes

@jernstlun,

you can place stuff you want to do in a function and use STARTUP()

https://docs.particle.io/reference/firmware/photon/#startup-

1 Like

Just using SYSTEM_THREAD(ENABLED) I get 50 milliseconds from power-on to the start of PWM using this code. One probe is 3V3 and the other is D2.

#include "Particle.h"

SYSTEM_THREAD(ENABLED);

void setup() {
	pinMode(D2, OUTPUT);
	analogWrite(D2, 128);
}

void loop() {	
}

2 Likes

Thanks, guys, for all the help. It works just as you said!!

1 Like