I2C Master and Slave with one ESP32 board

TomasCZ
Posts: 39
Joined: Tue Apr 25, 2023 5:19 am

I2C Master and Slave with one ESP32 board

Postby TomasCZ » Mon Jun 26, 2023 8:46 am

Dear all, please, can I use one ESP32 board as Slave and Master for two I2C devices ? I sniff I2C data from an external I2C device (data for an OLED display) (SLAVE role) and would like just for testing for purposes to forward the data to an OLED display (MASTER role).
Thank you in advance.

MicroController
Posts: 1708
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: I2C Master and Slave with one ESP32 board

Postby MicroController » Mon Jun 26, 2023 11:02 am

ESP32 has 2 I2C controller (also referred to as port) [...]. A single I2C controller can operate as master or slave.
So yeah, it should be possible to have one controller as a slave and one as a master.

However, the ESP-I2C controllers are a bit "special" in what they can and cannot do in slave mode. Just auto-ack'ing and piping through all non-address bytes received should be feasible though.

nochkin
Posts: 8
Joined: Tue Jun 20, 2023 5:04 am

Re: I2C Master and Slave with one ESP32 board

Postby nochkin » Tue Jun 27, 2023 4:07 pm

I would highly recommend to get a simple logic analyzer. I2C protocol is slow enough and you can get a cheap logic analyzer using 8 channels and 24MHz for like $10-$20 or so.
It will let you analyze I2C and even extract the exact data it's being sent over to your device.
It works completely transparent for both ends.

TomasCZ
Posts: 39
Joined: Tue Apr 25, 2023 5:19 am

Re: I2C Master and Slave with one ESP32 board

Postby TomasCZ » Wed Jun 28, 2023 9:27 am

Yes, I use a copy of Salae logic analyzer to sniff the data from the I2C bus to comepare the data with the data sniffed by the ESP32 board. There is long way behind from Arduino Nano/UNO boards to ESP32 boards used with Arduino IDE to ESP-IDF where we finally got the same data as from the logic analyzer. No I am trying to check the reliability and playing with the buffer size and the portTICK_PERIOD_MS value.

Next step would be to test the data sniffed by the ESP board with the OLED display before we start to re-write everything made in IDE to ESP-IDF.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 139 guests