# I2C Communication

### Master request/send data

The master sends data to and requests data from slaves, including an 8-bit packet ID. Each slave uses this ID as an index into its callback function array to determine which function to execute.

<figure><img src="/files/vuob4DzVKf9umPCymsWr" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/eQjgfxYSdkJYfAiW03Th" alt=""><figcaption></figcaption></figure>

### Slave Return

Upon a request, the slave responds with a message containing a slaveCallbackIndex. The master uses this ID to select the corresponding callback function.&#x20;

<figure><img src="/files/DpaHmA82f98RQ2rPZcIr" alt=""><figcaption></figcaption></figure>

### I2C Setup Master

The examples use the DOIT ESP32 DEVKIT V1 as the master. The ESP32 is connected to the Feelix motors through the Feelink board.

<figure><img src="/files/UGjmGr22jZFNFTg9eoxz" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Default I2C pins on DOIT ESP32 DEVKIT are \
SCL GPIO22 \
SDA GPIO21\
\
Alternatively you can use \
SCL GPIO32 \
SDA GPIO33
{% endhint %}

### I2C Setup Slaves

The slaves can be connected with JSH cables to the FeeLink board.\
The **3.3V outputs** do **not** have to be connected.

<figure><img src="/files/XplxkmXrxd9PJYsOhh1e" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.feelix.xyz/downloads/c-library/arduino-library-documentation/i2c-communication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
