ESP32 Bit Pirate home
  • GPIO / I2C / SPI
  • Intermediate
  • 10 min
  • BPIO2 + Web Tools

Recipe · Intermediate · GPIO, I2C, SPI, USB

How to use the BPIO2 GPIO, I2C and SPI adapter

Expose eight ESP32 GPIOs over USB CDC for direct pin control and I2C or SPI transactions. BPIO2 uses a binary protocol for repeatable operations from software.

USB adapter and host-tool workflow.
One USB adapter for GPIO control, I2C/SPI transfers and browser automation.

Compatible web tools

Both tools support the BPIO2 adapter: use the controller for direct interaction or Python Lab for scripts.

Step 1

Enable the BPIO2 adapter

In the Bit Pirate terminal, open the USB adapters menu:

mode usb
adapters

Select BPIO2 GPIO/SPI/I2C and assign eight unique GPIOs to IO0 through IO7. Keep the mapping handy. The board reboots into BPIO2 mode over native USB; close the terminal before connecting a web tool.

Step 2

Wire the selected IOs

IO0–IO7 are adapter labels, not ESP32 GPIO numbers. Use the GPIOs assigned in Step 1 and connect adapter GND to target GND.

BPIO2 pinHiZ modeI2C modeSPI mode
IO0GPIOGPIOCS
IO1GPIOSCLSCK
IO2GPIOSDAMOSI
IO3GPIOGPIOMISO
IO4–IO7GPIOGPIOGPIO
GNDTarget GND

HiZ makes all eight IOs available as GPIOs. I2C reserves IO1/IO2; SPI reserves IO0–IO3. The remaining pins stay available as auxiliary GPIOs.

Step 3

Open the web controller

Open the Web Bit-Bang Controller, click Connect and select your board's port.

Use the tabs to control pins, exchange data or run a sequence.

Step 4

Automate with Python Scripting Lab

Web Python Scripting Lab also connects directly to this adapter. Disconnect the controller, open Python Lab and select a BPIO2 example from Scripts, or import a compatible script. Click Run and select the adapter port when prompted.

Use BPIO2 scripts to repeat transfers, collect readings or build hardware checks. They use the binary adapter API; ordinary Bit Pirate CLI commands require normal CLI mode. No local Python installation is needed for the web lab.

Result

What success looks like

The controller reports the adapter and its pin mapping. GPIO states update, or your I2C/SPI target returns the expected data. Python Lab can automate the same adapter through BPIO2.

To return to the Bit Pirate CLI, disconnect the web tool and reset the board. Enable BPIO2 again for another adapter session.

Troubleshooting

  • Port busy: Disconnect the terminal or other web tool; only one client can use the serial port at a time.
  • No BPIO2 response: Confirm the adapter was selected and the board rebooted. Use a browser with Web Serial support.
  • Wrong pin or no data: Check the IO-to-GPIO mapping, shared ground and target power. Pins reserved by I2C/SPI are controlled by the active bus.

Go deeper