ESP32 Bit Pirate home
  • I2C
  • Advanced
  • 3 min
  • Serial CLI

Recipe · Advanced · I2C

How to emulate an I2C slave

Use I2C slave mode to listen as a target address and log master operations.

I2C bus with SDA and SCL signal lines.
Start with read-only checks, then move to write, replay or automation only when the setup is understood.
Step 1

Commands

Use the shortest command path that matches the documented firmware workflow. When a mode needs setup, follow the prompts shown on first entry.

Result

What it means

The command path is working when the target responds and the firmware prints the expected menu, status or captured data.

Troubleshooting

  • Re-enter the mode setup when pins or peripherals are not already initialized.
  • Check common ground and target voltage before blaming software.
  • Prefer Serial CLI for long captures or high-volume output.
  • Repeat the read or capture to confirm stability.

Next steps

  • Save the output in your project notes.
  • Compare the result with the full wiki page for mode-specific details.
  • Create a shorter alias if you repeat this workflow often.

I2C slave emulation FAQ

When is I2C slave emulation useful?

Use it when you want to observe how a master writes or reads from a chosen address without the original peripheral attached. It is useful for firmware debugging and protocol discovery on your own bench.

Can I emulate any I2C device perfectly?

No. Real devices may have timing limits, register maps, interrupts, state machines and side effects. Slave mode is best for logging master operations or simple responses, not a perfect hardware replacement.

What address should I choose for I2C slave mode?

Choose the 7-bit address the master expects, and make sure no real device with that address remains on the bus. Two devices acknowledging the same address will make the capture unreliable.

Go deeper