ESP32 as an I2C slave

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
wonde05
Posts: 26
Joined: Thu Apr 08, 2021 12:53 pm

ESP32 as an I2C slave

Post by wonde05 » Thu May 05, 2022 1:09 pm

I was trying to set the esp32 as an I2C slave and I could only find the Boris Lovosevic's version of micropython firmware which supports I2C slave mode.

Code: Select all

https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/i2c
The lobo's version doesn't have some features like i2s support so I spent a lot of time trying to merge lobo's version with the main micropython but I couldn't figure it out. Is it even possible to merge the two versions ?

tepalia02
Posts: 99
Joined: Mon Mar 21, 2022 5:13 am

Re: ESP32 as an I2C slave

Post by tepalia02 » Fri May 06, 2022 10:59 am

Hi, have you checked this document too?
https://micropython-docs-esp32.readthed ... b.I2C.html

wonde05
Posts: 26
Joined: Thu Apr 08, 2021 12:53 pm

Re: ESP32 as an I2C slave

Post by wonde05 » Fri May 06, 2022 11:29 am

Yes I did but that one is specific to the pyboard.

tepalia02
Posts: 99
Joined: Mon Mar 21, 2022 5:13 am

Re: ESP32 as an I2C slave

Post by tepalia02 » Sat May 07, 2022 11:01 am

From this old thread, it looks like ESP-32 cannot be configured as a slave: viewtopic.php?t=10203
Let's see if anyone has anything else to offer.

Lobo-T
Posts: 36
Joined: Tue Nov 16, 2021 2:36 pm

Re: ESP32 as an I2C slave

Post by Lobo-T » Sat May 07, 2022 12:01 pm

The ESP32 has hardware support for I2C slave. But it is not made available in Micropython.
You probably could get it to work by manipulating the i2c registers directly. I know someone did that for the Raspberry pico (completely different architecture, so doesn't help you).

What is your master? The easiest solution might be to switch who is master and slave.

wonde05
Posts: 26
Joined: Thu Apr 08, 2021 12:53 pm

Re: ESP32 as an I2C slave

Post by wonde05 » Sat May 07, 2022 4:36 pm

@tepalia02 thanks for your answer.
@Lobo-T I am using esp32 as master may be I'll try manipulating the i2c registers like you said or I can always use another board with slave support Its just right now I only have esp32. I hope the next micropython version includes slave support for the esp32.

Lobo-T
Posts: 36
Joined: Tue Nov 16, 2021 2:36 pm

Re: ESP32 as an I2C slave

Post by Lobo-T » Sat May 07, 2022 4:56 pm

Are there any other devices on this i2c bus? If it's only the two ESP32s, have you considered just using UART between them instead?

wonde05
Posts: 26
Joined: Thu Apr 08, 2021 12:53 pm

Re: ESP32 as an I2C slave

Post by wonde05 » Sat May 07, 2022 5:27 pm

yes there are other esp32's on the bus I chose the i2c because I was trying to communicate with multiple slave esp32's and I thought that i2c would be easier to implement that.

Post Reply