- Muchas notas - Fran Acién

20230921 - i2C tools on ESP32

It is possible to use the next i2c_tools in esp32

  • It doesnt work in the esp32s3 dev board
  • It works in the esp32 board

How to

Download esp idf, and export the variables with . ./export.sh

$ cd examples/peripherals/i2c/i2c_tools
$ idf.py set-target esp32
$ idf.py -p /dev/serial/by-id/usb-Espressif_USB_JTAG_serial_debug_unit_F4:12:FA:DF:28:30-if00 flash monitor

To exit you need to push 2 times the Ctrl+]

Pinout

Esp32:

  • SDA: GPIO18
  • SCL: GPIO 19

Example

I connected a simple sensor (mcp4725). It is connected, no resistors or anything. And the output is the next one:

i2c-tools> i2cdetect
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: 00 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- 62 -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

From adafruit :

  • A0 allow you to change the I2C address. By default (nothing attached to A0) the address is hex 0x62. If A0 is connected to VDD the address is 0x63. This lets you have two DAC boards connected to the same SDA/SCL I2C bus pins.

Some examples:

i2c-tools> i2cdump -c 0x62
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0    ????????????????
10: c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0    ????????????????
20: c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0    ????????????????
30: c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0    ????????????????
40: c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0    ????????????????
50: c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0    ????????????????
60: c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0    ????????????????
70: c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0 c0    ????????????????

Checkout that the wiring of the sensor has a 10k resistor.

8e5ac1c287668c407fb63def9deccda0.png