Hello,
I would like to investigate the ability to monitor an I2C data-bus as a troubleshooting tool.
I would like to be able to connect the Arduino up to a current I2C bus and simply watch the data on that bus - on the IDE serial monitor.
I suspect someone has already done that?
Can anyone point me in the direction of where I might find an example sketch/program?
The data usually go by far too fast to be observed by printing on the serial monitor.
Most people use a multichannel logic analyzer to do bus analysis and troubleshooting. They need not be expensive (this absolutely minimal example (PC also needed), might work for your project).
Have a look here for a few I2C sniffers. They don't work in real time as it were. They capture I2C activity for a short period of time - usually until their memory buffers fill up, and then print out what they've captured on the serial monitor. They are also usually limited to an I2C bus running at 100kHz. I don't think any of them will handle a 400kHz bus.
As suggested, a cheap LA can be had for around 10 GBP on eBay. There's some great PC software that will decode the captured I2C data for you (SigRok?) . I think even the cheap LAs also capture SPI data and standard UART data as well as discrete logic signals.
They are a really useful tool to have - even a really cheap one.
The unit linked by jremington coupled with the Pusleview software is a great troubleshooting tool. The Pulseview software even has an I2C decoder that will show what is sent and received.