
How it works
ESP-IDF's i2c_basic example is a minimal I2C master. It opens I2C port 0 with SCL on GPIO4 and SDA on GPIO5, enables the internal pull-ups and adds the sensor at address 0x68. It reads one byte from the WHO_AM_I register at 0x75 and logs it, writes the reset bit to the power management register at 0x6B, removes the device and the bus, and returns from app_main().
The upstream code was written for an MPU9250, whose WHO_AM_I value is 0x71. The bench part is an MPU-6050, which answers 0x68 from the same register, so the log reads WHO_AM_I = 68. That difference is real and is kept: the program is not changed to suit the part. The sensor runs from the module's 3V3 output, and a 5 V battery on SIM VIN powers the S31.
What to watch
Enable verbose in Serial to see I2C initialized successfully, WHO_AM_I = 68, I2C de-initialized successfully and Returned from app_main(). The program runs once; restart the board to run it again.
What's on the bench
- Battery
- ESP32-S31 (development source)
- MPU-6050
How it's wired
- Battery · pos→ESP32-S31 (development source) · vin
- Battery · neg→ESP32-S31 (development source) · gnd
- ESP32-S31 (development source) · 3v3→MPU-6050 · vcc
- ESP32-S31 (development source) · gnd→MPU-6050 · gnd
- ESP32-S31 (development source) · g4→MPU-6050 · scl
- ESP32-S31 (development source) · g5→MPU-6050 · sda
This project runs prebuilt firmware on the emulated board; open it in the simulator to watch it work and inspect every part live.
Try this
- Enable verbose and confirm WHO_AM_I = 68 before you disconnect SDA. Disconnect the SDA wire and restart. Nothing answers at 0x68 any more, so the line WHO_AM_I = 68 does not appear.
- Compare the logged value with the source comment, which expects 0x71 from an MPU9250. A different chip at the same address returns a different identity byte, which is exactly what the WHO_AM_I register is for.
- Open the S31 OLED graphics demo next. It uses the same GPIO4 and GPIO5 bus to drive an SSD1306 at 0x3C.



