My Photon's device keys are getting corrupted after every power failure

Every thunder storm, wind storm, or brief power transient in my house, my Particle Photon stops working completely. It gets stuck in flashing blue "listening mode", regardless of whether you try to run it in safe mode or not.

And every time this happens, I have to go into the Android app, tell it my wifi credentials again, and THIS gives me the "3 cyan, 1 red" flashing sequence.

THEN I have to plug the Photon into my PC, and run this sequence of commands in the command line (something about particle keys doctor):

And only then is it fixed. It's a real PITA to have to do this every single time there's a power outage, is this something I can prevent? It doesn't seem to matter what kind of power supply the Photon is plugged into, I've used everything from a mobile phone's 2A charger, to the USB port coming out of a desk lamp.

@moeburn, that is weird. Can you provide more details on what you have connected to your Photon, which pins you use and how everything is powered (the connected devices). How long is your USB cable from the charger to the Photon? Is the Photon on a protoboard or on a PCB? Pictures would be helpful.

Sure, here’s a photo of the whole setup:

It’s running a BME280 weather sensor and outputting to a small TFT LCD. The only external connection is the USB power to the photon itself.

It’s got to have something to do with either my particular circuit, or this particular Photon, because I’ve got another one running outside (albeit a very different circuit with different components) on a weather pole and it survives the exact same power failures without issue. And the one outside uses a very long USB cable with another USB extension cable, which would produce a bit of voltage drop, and it works just fine, so I don’t think it’s the inside one’s cable. And I’ve used multiple cables and chargers with the inside one and had this issue on both. It’s got to be either my circuit, or the particular unit.

Thanks for your help!

There is a uncommon condition where a Particle device can lose its keys when a brown-out occurs and power drops below its operating voltage. This is most likely what is happening. Why it does it on this particular Photon all the time, I can’t explain. You could put a large capacitor (470uF) on the board between Vin and GND, near the Vin pin. If you have a 0.1uF cap, you could put that in parallel as well. It wouldn’t hurt to put a decoupling cap at the 3.3v input to the BME280. These are a bit of a fishing expedition since I can’t see anything obviously wrong otherwise.

@moeburn, which version of System Firmware are you running on that Photon?