esp-idf/examples/peripherals/i2c
Roland Dobai 27a63c492f Examples: Demonstrate the usage of esp_err_to_name 2018-03-13 14:27:00 +01:00
..
main Examples: Demonstrate the usage of esp_err_to_name 2018-03-13 14:27:00 +01:00
Makefile Moved examples to new folders / categories. Removed example numbers from example names 2017-01-16 23:08:35 +01:00
README.md Moved examples to new folders / categories. Removed example numbers from example names 2017-01-16 23:08:35 +01:00

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
  • 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).