> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oryx.mechatronstudio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# I2C generator

> Create SDA and SCL buses with devices, reads, writes, and replies.

I2C uses two lines: **SDA** carries data and **SCL** marks when it is read. A **master** begins an exchange with a **device** identified by its address. The generator draws START, address, read or write bit, data, ACK or NACK replies, and STOP on both channels.

You can create the full range of I2C signals supported by the generator: **7-bit and 10-bit addresses**, writes, reads, probes, repeated STARTs, unresponsive devices, data NACKs, multiple masters, arbitration, high-speed mode, clock stretching, and up to **eight buses** when channels are available. Each bus requires **two channels**, SDA and SCL.

## Create your first transfer

**1. Open I2C**

In digital mode, click **Generators → I2C**. Start with **I2C 1**.

**2. Add a device**

Click **Add a device to the bus** and pick a common device or enter an address such as `0x3C`. You can also type `@` in the message box and select a device. It joins the bus group.

**3. Choose an operation and bytes**

Select **Write** to send data. In hexadecimal mode, enter `00 AF` and press **Enter** or **Add to the signal**. The generator draws START, the address, ACK, both bytes, and STOP.

**4. Inspect both lines**

Use **Show in the signal** to select the range on SDA and SCL. Sent messages appear on the right of the chat; reads appear on the left.

## Devices and addresses

The group bar holds the bus's devices. Add a common model or add one **by address**, give it a name and color, mention it with `@`, or remove it. Each address belongs to one device per bus; the panel prevents duplicates. The generator supports up to **128 devices per bus**.

| Address | How to enter it | Example |
| - | - | - |
| **7-bit** | `0x00` to `0x77`, except `0x04` to `0x07`, which are reserved for Hs master codes | `0x3C` |
| **10-bit** | `0x000` to `0x3FF`; enter three hexadecimal digits | `0x1A5` |

Some datasheets give an **8-bit address** that includes the read or write bit. If you enter `0x78`, for example, the panel suggests the 7-bit address `0x3C`.

> [!NOTE]
>
> **Not answering** on a device simulates a disconnected device: the address gets a NACK in all its messages. You can also change the reply for an individual message with its **ACK or NACK** control.

> [!TIP]
>
> The generator leaves **SCL as TX** and **SDA as a shared line (TX/RX)**. When running on the ESP32, the device drives SDA open drain, releases it on the acknowledgements and on the bytes it reads, and compares what the real device answers with the drawing (see [Reception](https://docs.oryx.mechatronstudio.com/en/device/reception.md)).

## Message controls

| Control | Effect |
| - | - |
| **Write** | The master sends bytes; the device acknowledges with ACK |
| **Read** | The device supplies the chosen bytes; the master ends the last with NACK |
| **Text, hexadecimal, decimal** | Three ways to enter data, such as `00 AF` in hexadecimal |
| **Address only** | With **Write** and an empty box, press the add button to make a probe like an I2C scanner |
| **ACK or NACK** | Keep a normal reply, make the address unanswered, or reject a write byte; a NACK releases the bus |
| **Repeated START** | Continue as the same master without releasing the bus; useful for writing a register number, then reading it |
| **Hs** | Send the master code at normal timing, a repeated START, and the rest at high-speed timing |

### Example: read a register

**1. Specify the register**

Mention the device, choose **Write**, and enter a register number such as `00`. Add the message.

**2. Read its value**

Choose **Read**, enter the bytes the device returns, such as `19 2A`, and turn on **Repeated START** before adding. The bus remains held between the two messages.

## Multiple buses and masters

The **I2C 1** selector adds buses up to eight, provided each has two free channels. Each bus has its own SDA, SCL, devices, and timing. Add a message to the current bus before adding the next. Bus options let you show its channels, change its color, or delete it. Deletion also removes that bus's messages, devices, and channels.

Add up to **eight masters per bus**. The first is the usual microcontroller. Choose **Who is talking** to assign messages to them. If two different masters start **In parallel** on the same bus, the signal shows **arbitration**: one wins, and the other retries when the bus is free. If they send exactly the same thing, there is only one transfer on the wire. On separate buses, **In parallel** makes simultaneous transfers without arbitration.

> [!NOTE]
>
> **Repeated START** and **In parallel** are alternative choices for one message. Repeated START works only when the preceding message is on the same bus and master and did not end with NACK.

## Timing, pauses, and existing signals

In **Settings**, set **Between messages** (steps with SDA and SCL high between STOP and START) and timing **per bus**:

| Setting | Effect |
| - | - |
| **Steps per bit** | Duration of each bit: by default **2 steps**, one with SCL low and one with SCL high |
| **Clock held after each ACK** | Extra steps with SCL held low by the device (*clock stretching*) |
| **Steps per bit in Hs** | Timing of bits in high-speed messages |

The step playback rate determines the bus's real speed. If you have already drawn SDA and SCL, the panel can **read the existing bus**: choose which channel is data and which is clock, then click **Read messages**. Transfers found appear in the chat. A notice identifies details of a hand-drawn signal that the chat cannot represent; changing the generator rebuilds the bus from its messages, and you can undo that action.

For transfer fields and decoding errors, see the [I2C interpreter guide](https://docs.oryx.mechatronstudio.com/en/protocols/i2c.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.