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.
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.
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.