Skip to content
Koepel edited this page Jan 7, 2023 · 5 revisions

I2C Sniffers

To analyze the I2C data on the bus, there are a number of options.

Logic analyzers

Oscilloscopes sometimes have logic analyzers builtin that can also decode the I2C protocol.
A USB logic analyzer is cheaper and the computer can be used to read the I2C protocol. The two cheapest options which work very well are:

  • A 10 dollar 8 channel 24 MHz USB logic analyzer with sigrok / PulseView software.
  • A 25 dollar LHT00SU1 (8 channel 24 MHz and 1 analog channel at 12 MHz) with sigrok / PulseView.

The quality of the hardware of the 10 dollar logic analyzer is not very good. The LHT00SU1 logic analyzer works very well and the analog channel is a bonus. Turn off the analog channel in PulseView to be able to use the digital inputs at high sample rates.

The USB logic analyzers can capture a large amount of data and it is easy to look into the data to find the right spot.

I2C Sniffers with ATmega, ATtiny and Arduino (compatible) boards

A Arduino board or a ATmega or ATtiny as a logic analyzer is not a serious tool. It is a gimmick, and it is hard to find the wanted data.

The ATtiny uses a USI for serial and I2C communication. The USI is very flexible and can be set as I2C Sniffer: I2C (TWI) Sniffer (not Arduino code).

The i2c-sniffer by Teknoid uses a Arduino sketch for the Arduino Nano or Uno with interrupts to read the data.

The i2c-sniffer-v3.ino from Mark Durham does not use interrupts, it reads the input pins at a high rate.

When a Arduino board is a Slave, it is possible to add another Arduino board as a Slave which is invisible on the bus and read also the data. To make it invisible a diode and pullup resistor is used for the SDA and SCL pins. There is a discussion at avrfreaks.net about it.

A ESP32 is faster and can keep up to 400kHz with this I2C Sniffer: https://github.com/WhitehawkTailor/I2C-sniffer
Note that the pins of the ESP32 are not 5V tolerant.

The Raspberry Pi Pico can be a Logic Analzyer and the software sigrok/PulseView can decode the I2C protocol: https://hackaday.com/2022/03/02/need-a-logic-analyzer-use-your-pico/

Emulating or man-in-the-middle

On the forums there is sometimes a question to be able to emulate a I2C chip for a existing device, or use the Arduino as man-in-the-middle to be able to change the I2C data between a Master and a Slave. In most cases that is not possible. The Arduino uses both hardware and software for the I2C, and therefor it is slower than a normal I2C chip. The Arduino uses "clock pulse stretching" (it keeps SCL low) to run the onRequest handler. If the Master does not support that, then it is not possible.

In an existing device, it is unlikely that a Master supports the "clock pulse stretching". The man-in-the-middle approach uses also the "clock pulse stretching" and the data from an existing Slave might not be ready, because that has to be retrieved somehow.

If the Master is a Arduino board, and it is know what kind of data is requested, then it is possible to emulate a EEPROM or sensor with an Arduino board.