I2C Communication

Understanding I2C Addresses

When we use I2C communication, more than one device can be connected to the same two wires.

So how does the microcontroller know which device to talk to?

Each device has its own I2C address.

What is an I2C Address?

An I2C address is just a number given to a device.

The microcontroller uses this number to choose which device it wants to communicate with.

Simple Example

Imagine you are calling someone on the phone.

An I2C address works the same way.

For Your OLED

Your OLED usually uses the address:

0x3C

This means the microcontroller sends data to 0x3C, and the OLED responds.

How many addresses exist?

I2C uses 7-bit addresses. That means there are 128 possible numbers (from 0x00 to 0x7F) that a device could use.

However, some addresses are reserved for special purposes, so not all 128 are available for normal devices.

Why the OLED has two addresses

Even though I2C supports many addresses, your OLED module only allows two possible addresses:

You only need the alternative address (0x3D) if you want to connect two OLEDs to the same I2C bus. Each device on the bus must have a unique address.

How this works in code

When initializing the OLED in your Arduino code, you write:

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

If your OLED jumper is changed to 0x3D, you must update the code to:

display.begin(SSD1306_SWITCHCAPVCC, 0x3D);

This ensures the microcontroller talks to the correct device.

Summary in simple words

Understanding SCL and SDA (I2C Communication)

The OLED display uses a communication method called I2C. I2C allows devices to talk to each other using only two signal wires.

What is SCL?

SCL stands for Serial Clock Line.

Think of SCL like a heartbeat or rhythm that keeps everything in sync.

What is SDA?

SDA stands for Serial Data Line.

If SCL is the rhythm, SDA is the actual message being sent.

Why Are Both Needed?

Both wires work together to make communication possible.

Where Do You Connect Them?

On the RP2040 board, there are specific pins labeled:

You must connect:


        OLED SCL → RP2040 SCL pin
        OLED SDA → RP2040 SDA pin
        

Do not swap them. SCL must connect to SCL, and SDA must connect to SDA.

Complete Connection Summary


        OLED        →     RP2040
        -----------------------------
        GND         →     GND
        VCC         →     3.3V
        SCL         →     SCL
        SDA         →     SDA
        

Only four wires are needed because I2C communication shares the same two signal lines (SCL and SDA).