To use the Wire.h library in your Arduino project, follow these steps:

If you’ve just started a project involving an I2C device—like an OLED display, a temperature sensor (BMP280), or an RTC (Real Time Clock)—you have likely encountered the following line at the top of an example sketch:

When using Wire.h, you must plug your devices into the correct pins: SDA is A4, SCL is A5. Arduino Mega: SDA is 20, SCL is 21. Arduino Leonardo: SDA is 2, SCL is 3. ESP32: SDA is GPIO 21, SCL is GPIO 22 (usually).

Wire.h depends on internal Arduino architecture. A random standalone file won’t work.

void loop() // Your I2C communication here