Ok, I've added the code found in this post:
Just added an additional check for the status of the switch.
Particle.connect();
if (!waitFor(Particle.connected, msRetryTime) || digitalRead(D5) == LOW)
{
WiFi.off(); // no luck, no need for WiFi
RGB.control(true);
RGB.color(0, 0, 0);
}
It seems to have done the trick. The temp sensor is working whether or not the Photon is connected to wifi. This addition has raised a few other questions though.
- Without the 500ms delay in the loop, the one-wire communication fails again, no matter the wifi connection status. Why is that delay so crucial in this instance? I thought delays in the loop were generally bad practice?
- When re-flashing the firmware, the behavior is noticeably different with this code installed. The RGB LED solidly blinks magenta rather than the rapid blinks, and it takes a little bit longer than usual. Is this normal behavior while listening for the connection semi-automatically?
- Do Time functions, like Time.now(), work even if the Photon is not connected to WiFi or the cloud? It seems to be polling the time accurately when wifi is off and it's disconnected from the cloud. I always assumed the Photon received its time from the router to which it was connected. If there's no internet connection to retrieve the time from, will my time functions stop working or is that information stored internally on the Photon somewhere?
Thanks for your help! The time.format did help save a ton of cycles.