I am having a i2c problem with the Photon (running 0.4.3). I do not have the problem with the Core modules.
After a random amount of time (a few minutes to several hours), the Photon will stop successfully reading from an i2c device. I have tried multiple i2c devices and multiple photons. I have pull-ups on the i2c pins.
Here is a simple program that shows the problem. It just does an i2c read over and over, and eventually the photon stops sending out the i2c read request. I only have one i2c device connected (MCP9808 temp sensor, but the problem occurs with other i2c parts too).
// i2c test program
void setup() {
Serial.begin(9600);
Wire.setSpeed(100000);
Wire.begin();
Wire.beginTransmission(0x18); // write to i2c address 0x18
Wire.write(0x06); // read from register 0x06
Wire.endTransmission();
}
void loop() {
Wire.requestFrom(0x18, 2); // request 2 bytes from i2c address 0x18
delay(1); // wait for chip to send data
if (Wire.available() < 2) { // display error if 2 bytes are not available
Serial.println("Error: data not available!");
// Wire.begin(); // this will reset the i2c into working again
}
else {
Wire.read(); // read the 1st byte (it is always 0)
Serial.println(Wire.read()); // display the 2nd byte (0x54)
}
delay(100);
}
Here is the logic analyzer display when the read is working correctly:
Here is the display after it stops working. Note that there is only the one SCL and SDA pulse. The read request with the i2c address is never sent out.