Arduino I2C sniffer
posted May 21st 2011 7:47am by Caleb Kraftfiled under: arduino hacks, tool hacks

[Johngineer] found himself in need of an I2C sniffer, but didn’t have one available. Necessity is the mother of invention, so he put together this I2C sniffer sketch for Arduino. The arduino will record what is going on for a set time interval, then dump the data via serial as a .csv. You then have to plot it to see what is going on. [Johngineer] recommends Livegraph, since it is portable and easy. As you can see in the code, the time interval is adjustable, but you have the physical limitations of the RAM on the board to consider. This seems like a pretty handy piece of code stored around, effectively giving you a passable I2C sniffer in a pinch.






Nice and handy for folk with Arduinos
I think a good way to get around RAM limitations would be set up an interrupt on the pin you’re monitoring and a timer which counts the time between edges. That way, you only need to store a byte (or two) for each edge which should give you plenty of space.
(Up to 2000 edges with 2K I suppose)