Free I2C tool
Find the I2C address before changing your code blindly.
Use these Arduino and ESP32 scanner sketches to find OLED, LCD, RTC, EEPROM, and sensor addresses. If nothing appears, follow the wiring checks before replacing the module.
Copy-paste scanner
Choose your board and upload the scanner.
Open Serial Monitor after upload. If the scanner prints an address like `0x3C`, use that address in your display or sensor library.
Arduino I2C scanner
For Arduino Uno and Nano, SDA is usually A4 and SCL is A5. For Mega, SDA is 20 and SCL is 21.
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
while (!Serial);
Serial.println("I2C scanner started");
}
void loop() {
byte error;
byte address;
int devices = 0;
Serial.println("Scanning...");
for (address = 1; address < 127; address++) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at 0x");
if (address < 16) Serial.print("0");
Serial.println(address, HEX);
devices++;
}
}
if (devices == 0) {
Serial.println("No I2C devices found");
}
delay(3000);
}
ESP32 I2C scanner
Enter the SDA and SCL pins you wired. Common ESP32 defaults are SDA 21 and SCL 22, but many projects use different pins.
#include <Wire.h>
const int SDA_PIN = 21;
const int SCL_PIN = 22;
void setup() {
Wire.begin(SDA_PIN, SCL_PIN);
Serial.begin(115200);
Serial.println("ESP32 I2C scanner started");
}
void loop() {
byte error;
byte address;
int devices = 0;
Serial.println("Scanning...");
for (address = 1; address < 127; address++) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at 0x");
if (address < 16) Serial.print("0");
Serial.println(address, HEX);
devices++;
}
}
if (devices == 0) {
Serial.println("No I2C devices found");
}
delay(3000);
}
Debug path
What to do with the scanner result.
FAQ
I2C scanner questions
Can two I2C devices use the same address?
Not on the same bus unless you use an I2C multiplexer or one device supports address selection. If two modules share the same fixed address, the scanner may behave unpredictably.
Why does the scanner find an address but my display still stays blank?
The I2C bus is working, but your library, controller type, address, screen size, or display initialization may still be wrong.
Do I need pullup resistors?
Many modules already include pullups. If wires are long, modules are bare, or the bus is unstable, external pullups may be needed.