Wire.h Library //top\\ May 2026

void loop() byte error, address; int devices = 0;

| Device | Typical Address | |--------|----------------| | OLED Display (SSD1306) | 0x3C | | RTC DS3231 | 0x68 | | Temperature Sensor (BMP280) | 0x76 or 0x77 | | EEPROM (24LC256) | 0x50 | | LCD Backpack (PCF8574) | 0x27 or 0x3F | Advanced Usage: Multiple Bytes // Sending multiple bytes Wire.beginTransmission(0x50); Wire.write(0x00); // Address high byte Wire.write(0x00); // Address low byte Wire.write("Hello"); Wire.endTransmission(); // Reading multiple bytes Wire.requestFrom(0x50, 10); while(Wire.available()) char data = Wire.read();

if(error == 0) Serial.print("Found device at 0x"); if(address < 16) Serial.print("0"); Serial.println(address, HEX); devices++;

void receiveEvent(int bytes) while(Wire.available()) char c = Wire.read(); Serial.print(c);

void loop() float temp = readTemperature(); Serial.print("Temperature: "); Serial.print(temp); Serial.println("°C"); delay(1000);

Always add pull-up resistors (2.2kΩ to 10kΩ) on both SDA and SCL lines to 3.3V or 5V. Basic Functions Master Mode (Most Common) #include <Wire.h> void setup() Wire.begin(); // Join I2C bus as master Serial.begin(9600);

delay(1000);

Wire.h Library //top\\ May 2026

void loop() byte error, address; int devices = 0;

| Device | Typical Address | |--------|----------------| | OLED Display (SSD1306) | 0x3C | | RTC DS3231 | 0x68 | | Temperature Sensor (BMP280) | 0x76 or 0x77 | | EEPROM (24LC256) | 0x50 | | LCD Backpack (PCF8574) | 0x27 or 0x3F | Advanced Usage: Multiple Bytes // Sending multiple bytes Wire.beginTransmission(0x50); Wire.write(0x00); // Address high byte Wire.write(0x00); // Address low byte Wire.write("Hello"); Wire.endTransmission(); // Reading multiple bytes Wire.requestFrom(0x50, 10); while(Wire.available()) char data = Wire.read();

if(error == 0) Serial.print("Found device at 0x"); if(address < 16) Serial.print("0"); Serial.println(address, HEX); devices++;

void receiveEvent(int bytes) while(Wire.available()) char c = Wire.read(); Serial.print(c);

void loop() float temp = readTemperature(); Serial.print("Temperature: "); Serial.print(temp); Serial.println("°C"); delay(1000);

Always add pull-up resistors (2.2kΩ to 10kΩ) on both SDA and SCL lines to 3.3V or 5V. Basic Functions Master Mode (Most Common) #include <Wire.h> void setup() Wire.begin(); // Join I2C bus as master Serial.begin(9600);

delay(1000);