ESP32 Bit Pirate home
  • I2C
  • Beginner
  • 5 min
  • Python Lab

Recipe · Beginner · I2C

How to run an I2C scan from Python Scripting Lab

Use the browser Python editor to switch ESP32 Bit Pirate into I2C mode and run a repeatable scan.

I2C bus with SDA and SCL signal lines.
A browser script is useful when the command sequence is simple, repeatable and still being edited.
Step 1

Connect safely

Wire the I2C target, then Open Python Scripting Lab. For this recipe the Bit Pirate must be connected through the normal serial terminal port because the script drives the CLI with Web Serial.

  • GND must be common.
  • Use a known-safe target voltage.
  • Close other terminals before connecting from the browser.
Step 2

Run the scan script

Use the default starter script or paste this minimal version. Python Lab adds the required async handling before execution, so the script can stay readable.

Result

What it means

The Output panel prints the scan result. If an address appears, the target acknowledged on the bus and you can move to a protocol-specific read recipe.

Troubleshooting

  • If the script stops at mode setup, re-run it after accepting the first-time I2C pin prompts.
  • If no device appears, check SDA/SCL wiring, pullups, target power and common ground.
  • If the browser cannot connect, close Web Serial Terminal, PuTTY or any local Python process using the same port.
  • If the script writes a report, download it from Generated files in the Output panel.

Next steps

  • Save the script from Code View when the workflow is stable.
  • Try a fetched repo script from the Scripts menu.
  • Move to local Python when you need unattended desktop automation.

I2C scan from Python Lab FAQ

Why automate an I2C scan from Python?

Automation makes repeated scans easier when you are moving wires, changing pull-ups or comparing devices. It also gives you output that can be parsed or logged.

Should I still learn the normal I2C scan command?

Yes. Python Lab is just a host-side way to call firmware commands. Understanding mode i2c, scan, ping and health makes the automated result easier to interpret.

Why compare a Python scan with a normal terminal scan?

The comparison separates bus problems from automation problems. If both scans agree, the wiring and bus state are likely the focus; if only Python fails, inspect the script flow and serial session.

Go deeper