kopia lustrzana https://github.com/espressif/esp-idf
![]() 2. update example comments and other minor changes 3. rename API: i2c_cmd_link_create/i2c_cmd_link_delete (+4 squashed commits) Squashed commits: [2e0ac3e] 1. coding style: add one space after condition key words. 2. modify i2c.h, use gpio_num_t instead of int, improve comments of return values 3. add i2c index in index.rst 4. add readme for i2c example [4991d92] update i2c.doc [88b672e] driver: i2c 1. add mux and spin lock to run in a thread-safe way. 2. modify example code [4eb15fe] driver: i2c code 1. add i2c master code 2. add i2c slave code 3. add i2c example code 4. add DRAM_ATTR for I2C array |
||
---|---|---|
.. | ||
main | ||
Makefile | ||
README.md |
README.md
I2C Example
-
This example will show you how to use I2C module by running two tasks on i2c bus:
- read external i2c sensor, here we use a BH1750 light sensor(GY-30 module) for instance.
- Use one I2C port(master mode) to read or write the other I2C port(slave mode) on one ESP32 chip.
-
Pin assignment:
- slave :
- GPIO25 is assigned as the data signal of i2c slave port
- GPIO26 is assigned as the clock signal of i2c slave port
- master:
- GPIO18 is assigned as the data signal of i2c master port
- GPIO19 is assigned as the clock signal of i2c master port
- slave :
-
Connection:
- connect GPIO18 with GPIO25
- connect GPIO19 with GPIO26
- connect sda/scl of sensor with GPIO18/GPIO19
- no need to add external pull-up resistors, driver will enable internal pull-up resistors.
-
Test items:
- read the sensor data, if connected.
- i2c master(ESP32) will write data to i2c slave(ESP32).
- i2c master(ESP32) will read data from i2c slave(ESP32).