Running code before cellular//wifi boot up?

Is there any way to run any code as soon as the Photon/Electron boots?

I have a TFT screen connected to a Photon/Electron and when you power it up it just lights up white until Particle device has finished connecting to the cloud and setup() is called.

Is there any way I can send some SPI data on power up? Even just holding a pin low to keep the backlight off would do it.

You may look into the docs for SYSTEM_MODE(SEMI_AUTOMATIC), SYSTEM_THREAD(ENABLED) and STARTUP()

Thanks Scruff, I had a read of the docs - very useful.

I’m using threaded mode as this is perfect I can display info while the device is connecting, including error info when it doesn’t.

Can you point me in the right direction for getting info back from the system? I’ve tried system events but the only info that gets returned is event ID 0, Param 32 and I can’t see what this is in the ENUM in the docs.

I’ve been looking at the cellular.ready() and particle.connected(). Would this be enough to display 2 status notifications icons? I’ve not managed to get the electron connected yet so both are false.

Is there any way to get a proper debug log from the system?

Add this at the top of your code and see what you get out via USB serial.

SerialLogHandler allLogs;  // activate all logs
1 Like