Photon I2C: still unreliable?


I’ve read as many of the prior posts on these boards as I can find, and I know that Photon Firmware 0.4.4 was recently released with a fix. I have been running my Photons with this firmware since day 1 - last Thursday, Aug 27 - and I am still having issues with I2C reliability over time.

I’ll provide an example.

I have a SparkFun Photon Weather Shield, and a SparkFun Photon Battery Shield powered by a 2000mAh Li-Po battery and a solar panel through a soldered-on barrel jack. The I2C pull-up resistors on the battery shield are disabled since both shields have them.

I used a slightly tweaked version of the code provided by SparkFun’s Hookup Guide for the weather shield – tweaks are mainly limited to adjustments for the wind vane sensor resistances, reading I2C for the battery fuel gauge, adding Spark variables, et cetera.

At first, I had my battery fuel gauge readings happening every loop, without delay (not that I needed to). I could get away with this for about 30 minutes before everything on the I2C bus went wacky. This is understandable; I was basically hammering it…

Once I realized the error of my ways, I moved the read to happen every second along with the rest of the sensors. This drastically increased the amount of time I could retrieve valid values – it’s been about 2 and a half days. This morning I woke up to more invalid readings.

Is there something that is still causing this? All of the various sensors are being read sequentially on every loop - should the reads be spaced by a delay?

I notice that the process of reading the Spark variables takes considerably longer in this “wacky” state; whether it’s from the processor being maxed out, or a block/timeout being hit somewhere, I do not know.

The only way I have figured out to resolve this issue remotely (as I plan to put this on my rooftop eventually…) is to re-flash the application code from Particle Dev.

If there is any way I can help, I am willing.

1 Like

I am also still having issues with my MCP23017 with basically the same issue as you described.

I hammer the bus and it goes crazy after a few mins. If I read/write ones person second it will last a free days before it stops working.


You can try to decrease the value of the default pull up resistors on the board. They are a bit too high at 10k ohms. I've changed mine to 1k ohm, but 2.2k ohm might be ok as well. At 10k they are quite capacitive. I believe this is something Sparkfun plans to change on future revisions of the shield.

Once the Baro sensor on the Weather Shield errors due to noise or bad clock edges... it will get stuck in that state until you reinitialize the sensor and/or library. I haven't looked into the fix here, but Sparkfun is aware of this and has plans to update their library. The other Humidity sensor is very robust.. you can pull the Photon out of the shield and plug it back in and that sensor will recover on it's own.

There are some timeouts in the Weather Shield library that I had changed from counter based to millis() based that made the timeouts work much better (the difference between what appeared to be locked up and just a slow erroring bus), but the Core and Photon I2C library still has a hard coded 100ms timeout, so once you get into an error'd state, trying to talk I2C will start generating a lot of 100ms timeouts. I'm not sure what version of the library you have, of if this was fixed in the Weather Shield library yet.

1 Like