ESP32 Bit Pirate home
  • I2C
  • Beginner
  • 5 min
  • Serial CLI or Web Serial Terminal

Recipe · Beginner · I2C

How to scan an I2C bus

I pulled a tiny sensor board from a parts box. No label, no datasheet, just four pins. Before writing code, I wanted to know if it was alive and which I2C address it used.

I2C bus with SDA and SCL signal lines.
The useful first test is not a driver. It is: power, ground, SDA/SCL, scan for ACK.

Wiring View

I2C board BP Module SDAI2C SDA GPIOModule SCLI2C SCL GPIOModule VCCcorrect supplyModule GNDBP GND
Generated from the wiring summary: I2C board to BP.
Step 1

Commands

The firmware I2C controller implements scan to check every valid address and print devices that ACK. The first time you enter I2C mode, Bit Pirate opens the configuration prompts automatically for SDA GPIO, SCL GPIO and frequency.

Result

What success looks like

Found device at 0x3C and Found device at 0x68 mean two targets acknowledged on the bus. Those addresses are common for OLED displays and RTC/IMU parts, but the scan is not full identification. It tells you where to probe next.

Troubleshooting

If the scan prints I2C Scan: No I2C devices found., do not jump straight to “dead board”. Check shared ground, swapped SDA/SCL, wrong voltage, missing pull-ups, and whether another controller is holding the bus. The I2C wiki also documents recover, which attempts to release SDA by clocking the bus.

  • SDA and SCL are swapped.
  • Ground is not shared between the module and Bit Pirate.
  • The module needs pull-ups that are not present on the board.
  • The target board is holding SDA low after a failed transaction.

Next steps

  • Run identify <addr> to browse known address mappings.
  • Use read <addr> <reg> only after you know which register is safe to query.
  • For EEPROM-looking devices, use the dedicated eeprom [addr] shell instead of raw dumps.

I2C scan FAQ

Does a scan identify the exact I2C chip?

No. A scan only tells you that a device acknowledged a 7-bit address. It narrows the search, but you still need markings, module documentation, safe register reads or the Bit Pirate identify helper before treating the target as a known part.

What does a successful I2C scan prove?

A successful scan proves that at least one device acknowledges a 7-bit address on the bus. It does not prove the register map, command set, memory size or voltage tolerance of that device.

Should I use 7-bit or 8-bit I2C addresses?

Use the 7-bit address printed by the scan, for example 0x3C or 0x50. Some datasheets also show shifted 8-bit read/write values, but Bit Pirate commands in this recipe expect the normal 7-bit address form.

Go deeper