Particle is losing wifi connection despite decent wifi signal strength

I'm running a BME680 gas sensor on a Particle Photon. Long story short, it really doesn't like its code being interrupted, or it produces ugly spikes in its data graph:

I downloaded my Particle cloud data csv, and found out it was disconnecting at the same times as the spikes in my graph - 21:13, 22:40, and 22:50 are the times of the 3 big spikes in the middle.

They list different network.disconnect.reasons - one disconnect is caused by a "reset", the other two are caused by "error"s. Scrolling further to the right, the cloud.disconnect.reason for all is "error".

But I've caught my device in this state before. It is flashing green, which means not even a wifi connection is present, let alone cloud connection.

But I am also tracking wifi signal strength, and it never comes close to what I would consider a threshold for disconnects (-85dB)

Is there something else I can do to improve the stability of this connection? Some wifi setting that reduces power or forces B mode or something like that? I can't understand why it would be disconnecting so frequently at -75dB when I have a NodeMCU running at -85dB for weeks without issue.

Are you using SYSTEM_THREAD(ENABLED);? You definitely should, because if you don't and block the loop for more than 10 seconds a Photon/P1 will go offline.

Another possibility is that your power supply is not big enough. Most gas sensors include a small heating element, which, combined with the power used by the device may be too large for your power supply, or if your device is powered by 3V3, the internal regulator. This would explain the resets. Since Wi-Fi transmission uses more power, it could also explain the disconnections.


I am now thank you, and would you look at that, no more ugly data spikes!

the spike on the left is before I added the SYSTEM_THREAD(ENABLED) code, the gap on the right is after a wifi disconnect with no spike, meaning the code was still running! Thank you!

I have tried many many power supplies, even the beefy one the Raspberry Pi requires, none helped. But the BME680 despite being a gas sensor is a microscopic one, optimized for battery power. I don't think it draws as much current as the classic MQ metal mesh ones.

What I've also done is switch to Semi Automatic mode, and disconnected from the Particle cloud, only to reconnect after a command from my Blynk IOT app so I can flash new firmware OTA without being connected ALL the time. Then I had to add that handy community NTP Time library (thank you whoever wrote that) so I could still have time without Particle cloud. Then I discovered that semiauto does not attempt to reconnect to wifi after a disconnect (hence that long gap on the right of the graph) only Particle cloud, so I had to add if(!WiFi.ready()) {WiFi.connect();} to the loop and hopefully that'll all work!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.