I2C Spy

Hi,

I've got an I2C communication going back and forth between a master and a slave and I would like to program an Arduino to serial print all the back and forth communications as well as the time they were sent. The problem I'm encountering is that with Wire.h, there doesn't seem to be a way to read out the bytes without interfering with the communication (ie, I can program the Arduino as a slave and simply have it print out all the communications I get, but not without it acknowledging the same address as the real slave, which creates problems). I thought I might be able to just modify the Wire.h source code and remove the line that tells the Arduino to acknowledge when its address is called, but the source code is basically gibberish to me.

ANYWAYS, does anyone have a clever, non-invasive, preferably easy solution that would allow me to print out all the communications between a master and a slave?

Thanks

Maybe use a software approach with interrupt. Not sure if you need falling or rising edge of the clock.When interrupt happens, read data bit.

@Beananator, please tell us which problem you want to solve. What device is the Master and what device is the Slave ?
Have you heard about the XY problem ?

With PulseView + sigrok + cheap hardware you can have a logic analyzer for less than 10 dollars.
There is also code for an ATtiny to make a I2C sniffer. The USI hardware inside the ATtiny is very versatile and can sniff the I2C bus.

To read the pins and pass them on to an other I2C device and trying to decode that data is very complex. I think it will not work.
To let the Arduino act as the Slave and meanwhile communicate with the Slave via an other (software) I2C bus, will probably also not work. It depends on the Master, but I doubt if it can be done reliable.

I'd get a logic analyzer (USB stick), and analyze the communication on the PC. This way I get the hardware, firmware and evaluation software at once, ready for use at little cost.

Koepel:
@Beananator, please tell us which problem you want to solve. What device is the Master and what device is the Slave ?
Have you heard about the XY problem ?

With PulseView + sigrok + cheap hardware you can have a logic analyzer for less than 10 dollars.
There is also code for an ATtiny to make a I2C sniffer. The USI hardware inside the ATtiny is very versatile and can sniff the I2C bus.

To read the pins and pass them on to an other I2C device and trying to decode that data is very complex. I think it will not work.
To let the Arduino act as the Slave and meanwhile communicate with the Slave via an other (software) I2C bus, will probably also not work. It depends on the Master, but I doubt if it can be done reliable.

The problem is pretty much exactly what I described. I need to monitor the communications between an I2C Master and Slave; if I can printout all of the read and write commands over a period of time I can interpret them.

I actually have a logic analyzer, but unfortunately, it's a little bit poor and doesn't include time stamps, just a list of all the communications, and the time stamps are critical for the analysis I need to perform. I thought I might be able to solve this with an Arduino but the vibe I'm getting is that the answer is no.

Is a library (DLL?) available for your logic analyzer? Then you can write your own logging program, that includes time stamps.

It is very hard for us to help you, if you don't want to tell what it is.

Is the Master an existing device or an Arduino ? Does it support clock pulse stretching ? Is it a 3.3V I2C bus or a 5V I2C bus ? Is it a I2C bus or a SMBus or one of those voltage controllers with a special SMBus ? What is the speed of the I2C bus ? What about the Slave ? Is that a 'dumb' sensor or a microcontroller ?

I can ask many more of those questions. If you want to know if it can be solved with an Arduino and how, then we have to know all of that.

My suggestion is to use or buy a better logic analyzer.