
It's provided some insight to me into this problem. Well, first of all thanks to all the input from all the people so far. But, I doubt anything is wrong with your copy of the Wire library. You might well have electrical problems on the I2C physical layer too. Sensor specific libraries, and software from that point of the stack on up, are where you should start looking for error recovery problems. The main reason I've been writing my own sensor drivers is that I want robust error handling.

The libraries written for hobbyists tend to have minimal error handling, and they don't always follow the datasheets. Typically, the sensor manufacturers provide datasheets, and, in the context of Arduino, the drivers usually come from third parties who sell the sensors on a breakout board for hobbyists. an Atlas sensor in TTL serial mode), or a mismatch between the bus master's clock speed and the min/max clock speeds supported by the cabling and the slave devices.įor talking to I2C slave devices with an Arduino, protocol state and error recovery are the responsibility of device specific drivers that-if you're lucky-follow the manufacturer's advice in the sensor datasheet for things like timing and how to configure registers.

But, it can have electrical problems like too much capacitance in the wiring, inadequately sized pull-up resistors, a device connected to the bus that isn't using I2C signaling (e.g. The bus doesn't have state, so it can't crash. I2C is a serial bus specification that uses open-drain signaling. Wire isn't supposed to reconnect to anything or do error recovery at the protocol layer-that's not part of its job.

Wire function calls return error codes about things like whether there was a timeout (according to the I2C bus timing specs) or how many bytes were read from a slave device. It provides low level primitives for reading and writing on the I2C bus. Wire is the standard I2C library for Arduino, Photon, and maybe other similar platforms. Are you familiar with I2C, Wire, and writing Arduino firmware? From your description, I think you may have misconceptions about what I2C and Wire do and how they work.
