ESP32 Bit Pirate home
  • I2C
  • Beginner
  • 5 min
  • Serial CLI

Recipe · Beginner · I2C

How to measure the I2C bus frequency

Probe SCL and run freq to find the clock rate of an active I2C bus.

I2C bus connected to an ESP32 Bit Pirate board.
Measure the clock produced by the existing I2C controller on SCL.
Step 1

Configure and connect SCL

Enter I2C mode and select the GPIO that will probe SCL:

mode i2c

Connect that pin to the target’s SCL and share GND. Leave the original controller connected. Use config to check the selected pin if needed.

Step 2

Measure the clock

Run freq with no arguments while the original controller generates I2C traffic:

freq

The command listens to SCL without generating traffic. Press Enter to cancel.

Step 3

Read and optionally save

Read Freq in kHz and the period, LOW and HIGH times in µs. A 10 µs period is about 100 kHz.

At Save frequency to the configuration?, choose y to update Bit Pirate’s I2C setting or n to leave it unchanged. The original controller’s clock is unaffected.

Result

Example report for a 100 kHz bus; actual values vary:

freq
=== Frequency Report ===
Freq: 100.00 kHz
Period: 10.00 us
LOW: 5.00 us
HIGH: 5.00 us
Cycles: 128/128
========================

What success looks like

Repeated measurements during traffic give a consistent SCL clock rate.

Troubleshooting

  • Still listening: Trigger traffic from the original controller; an idle bus has no clock to measure.
  • Unstable result: Check SCL selection, shared ground, pull-ups and short wiring.
  • Command unavailable: Use firmware and a board with I2C frequency capture support.

I2C frequency FAQ

Do I need SDA?

No. SCL and shared ground are enough for this measurement.

Is this the bus data throughput?

No. It measures the clock during transfers, without averaging in idle time.

Go deeper