๐Ÿ–‡๏ธ I2C: Inter-Integrated Circuit

I2C is the "Local Area Network" for the robot's sensory organs. Unlike point-to-point UART, I2C is a Shared Bus architecture that allows the ESP32 Controller to communicate with multiple peripherals using just two wires.

Core Role: Orchestrating the sensor suite, including IMUs (MPU6050), OLED displays, and Servo drivers.
Experimental Design View Source Code
SCL (CLOCK) SDA (DATA) ESP32 MPU6050 OLED SSD1306

Multi-Drop Shared Bus Architecture

๐Ÿ“Ÿ Protocol Logic: Synchronous Dialogue

I2C is a synchronous protocol. It uses a dedicated Clock (SCL) wire to synchronize data sampling on the Data (SDA) wire. This allows for reliable communication without baud-rate sensitivity.

โœ… Strengths

โš ๏ธ Weaknesses

๐Ÿ“ฆ The I2C Packet Sequence

Communication is always initiated by the Master (ESP32) through a bit-handshake:

START
ADDR (7-bit)
R/W Bit
ACK
DATA (8-bit)
ACK
STOP

๐Ÿงช Experimental Design: Pull-ups & Scanning

I2C lines are "Open-Drain" and cannot pull signals HIGH independently:

  1. Pull-up Resistors: We use 4.7kฮฉ resistors to return signals to 3.3V.
  2. Bus Scanning: Startup scan detects Hex IDs (e.g., 0x68); missing sensors trigger failsafes.
  3. Clock Stretching: Allows slower nodes (like Arduino Nanos) to pause the Master for processing.

๐Ÿ’ป Source Code Preview

Utilizing the Wire.h library on ESP32, we've optimized the bus frequency to 400kHz (Fast Mode) to ensure real-time balancing data from the MPU6050.