@DRCO , I’ve been able to use the equivalent of this simple code for now rare (when I cause it on purpose) connection problems once I got my router to play nice with the photons:
#include "application.h"
uint32_t lastTime;
void setup(){
//Your normal setup code here
}//setup
void loop() {
if (!Spark.connected()) {
//try reconnect forever
lastTime = millis();
while(!Spark.connected()) {Spark.process();}
}//if (!Spark.connected())
lastTime = millis();
while(millis() - lastTime < 1000) {Spark.process();}
if (Spark.connected()){
//normal loop code here
}//if (Spark.connected())
}//loop
We will be releasing 0.4.4 soon which has some WiFI stability fixes. If you’re hungry for them now, you can install from github releases in the firmware repo.
FWIW I’m having the exact same issue with my Photon and I was thinking it was some sort of code problem. Same code on the Core works fine. I’ve tried using both external antenna u.fL with code to select it in 0.4.3 firmware and the default chip antenna. When I look at the cloud log, it is going offline and coming back on as much a 3-4 times per hour. Every once in a while it hangs and never gets back on. Haven’t been able to figure out the problem.
Please try with the 0.4.4 firmware since this has some stability fixes for WiFi. (In 0.4.3 the code to select the external antenna was in fact selecting the internal antenna - the two were reversed.)
Upgraded to 0.4.4 and seems to have improved the problem quite a bit. I noticed that the closer the photon get to a power supply (mac power supply or a 12DC supply to run motor), the flakier the wifi gets. I’m assuming this is due to RF noise from the power supply that reduces the effective range of the photon. I was planning on attaching a housing with the photon in it to a motor to control a greenhouse vent, but I am concerned that this might cause the wifi to loose the connection when the motor is running. Thoughts on how likely this would be or how to best test this?