1# I2C Simple Example
2
3(See the README.md file in the upper level 'examples' directory for more information about examples.)
4
5## Overview
6
7This example demonstrates basic usage of I2C driver by reading and writing from a I2C connected sensor:
8
9If you have a new I2C application to go (for example, read the temperature data from external sensor with I2C interface), try this as a basic template, then add your own code.
10
11## How to use example
12
13### Hardware Required
14
15To run this example, you should have one ESP32, ESP32-S or ESP32-C based development board as well as a MPU9250. MPU9250 is a inertial measurement unit, which contains a accelerometer, gyroscope as well as a magnetometer, for more information about it, you can read the [PDF](https://invensense.tdk.com/wp-content/uploads/2015/02/PS-MPU-9250A-01-v1.1.pdf) of this sensor.
16
17#### Pin Assignment:
18
19**Note:** The following pin assignments are used by default, you can change these in the `menuconfig` .
20
21|                  | SDA             | SCL           |
22| ---------------- | -------------- | -------------- |
23| ESP I2C Master   | I2C_MASTER_SDA | I2C_MASTER_SCL |
24| MPU9250 Sensor   | SDA            | SCL            |
25
26
27For the actual default value of `I2C_MASTER_SDA` and `I2C_MASTER_SCL` see `Example Configuration` in `menuconfig`.
28
29**Note: ** There’s no need to add an external pull-up resistors for SDA/SCL pin, because the driver will enable the internal pull-up resistors.
30
31### Build and Flash
32
33Enter `idf.py -p PORT flash monitor` to build, flash and monitor the project.
34
35(To exit the serial monitor, type ``Ctrl-]``.)
36
37See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
38
39## Example Output
40
41```bash
42I (328) i2c-simple-example: I2C initialized successfully
43I (338) i2c-simple-example: WHO_AM_I = 71
44I (338) i2c-simple-example: I2C unitialized successfully
45```
46
47## Troubleshooting
48
49(For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you as soon as possible.)
50