> For the complete documentation index, see [llms.txt](https://docs.feelix.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.feelix.xyz/downloads/arduino-library-documentation/i2c-communication.md).

# 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="https://409642222-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3MZhIYg7iSyaPwgNKY%2Fuploads%2FvJl3gnjspOEH0dFonTJJ%2Fi2c_communication.svg?alt=media&amp;token=018c9fd2-8f9b-4a01-a22b-5b58cd69465a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://409642222-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3MZhIYg7iSyaPwgNKY%2Fuploads%2FM03n6lXEB0yNlOq9fRJn%2Fmaster_slave.svg?alt=media&amp;token=68770635-7e52-43ed-a92d-7ffb76b86f57" 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="https://409642222-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3MZhIYg7iSyaPwgNKY%2Fuploads%2Fr72mNCveelDnbPAmjeBw%2Fslave_master.svg?alt=media&amp;token=9b759bd9-8765-4e9e-b67d-11815247f9ff" 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="https://409642222-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3MZhIYg7iSyaPwgNKY%2Fuploads%2FzK40IIDIsgjo0H9LRzr3%2Fconnect%20esp.svg?alt=media&amp;token=b36182cb-ef99-472e-9603-2685c6dd4c78" 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="https://409642222-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3MZhIYg7iSyaPwgNKY%2Fuploads%2FIddwxn3fC4y1Co98UFaR%2Fconnect%20slave%20i2c.svg?alt=media&amp;token=c6f194cd-aff9-47e8-ab0c-188606e1e587" alt=""><figcaption></figcaption></figure>
