If an ESP32 I2C scanner finds no devices, confirm the SDA and SCL pins in your sketch, connect a common ground, and check that both bus lines idle high. Then scan one powered module at 100 kHz. This separates a wiring or bus problem from a problem in the sensor library.
Check the pins, ground, and pull-ups
On the Generic ESP32 board definition, SDA defaults to GPIO21 and SCL defaults to GPIO22. Other ESP32 boards can use different pins. Look up the pinout for your exact board, and match the GPIO numbers in the sketch to your wires. Connect both grounds and power the breakout according to its documentation. Espressif Arduino-ESP32 I2C reference
I2C uses open-drain lines, so pull-up resistors bring SDA and SCL high when no device is driving them low. Breakouts often include pull-ups. Check which voltage those resistors connect to before attaching the module. For this example, use a breakout with 3.3 V-compatible I2C lines. If the breakout pulls the lines to 5 V, check the module’s level-shifting requirements before connecting it. NXP I2C-bus specification
Run a 7-bit I2C scanner in Arduino IDE
This bench sketch scans the usual 7-bit range, skips the reserved ends, and prints each acknowledged address. It runs once after reset. Open Serial Monitor at 115200 baud, then press reset if you missed the output.
#include <Wire.h>
constexpr int sdaPin = 21;
constexpr int sclPin = 22;
void setup() {
Serial.begin(115200);
if (!Wire.begin(sdaPin, sclPin, 100000)) {
Serial.println("I2C initialization failed. Check the GPIO settings.");
return;
}
unsigned found = 0;
for (uint8_t address = 0x08; address <= 0x77; ++address) {
Wire.beginTransmission(address);
if (Wire.endTransmission() == 0) {
Serial.printf("ACK at 0x%02X\n", static_cast<unsigned>(address));
++found;
}
}
Serial.printf("Devices acknowledged: %u\n", found);
}
void loop() {}
An address in the output means a device acknowledged the probe. Check the module datasheet to identify it. If the datasheet lists separate write and read bytes such as 0x78 and 0x79, the corresponding 7-bit address is 0x3C. The two bytes differ in the least significant bit, which carries the read or write direction. Pass the 7-bit address to Arduino Wire. NXP specification on target addressing
If the scanner still finds no devices
- Initialization fails. Recheck whether the selected pins are available on your board and can be used for this bus.
- Either line stays low at idle. Power down and disconnect the modules one at a time. Reconnect a single module and check for a short, missing pull-up, or device holding the line low.
- Both lines idle high and nothing responds. Check for swapped SDA and SCL, verify power at the breakout, and shorten the leads. High idle voltage alone does not confirm that pulses reach the module.
- The scanner sees an address, but the library fails. Compare the 7-bit address with the library settings and check any address-select jumper. An ACK alone does not verify sensor data or register access.
Start with one known I2C breakout before reconnecting the rest. For examples of reading ESP32 debug output in a different setup, see Programming Boss’s Arduino and ESP32 serial communication guide.
Verification. The example was reviewed against Espressif’s Wire API and NXP’s address definitions. It was not compiled or run on hardware for this article. The hexadecimal values above illustrate address conversion.
