gutierrezps / ESP32_I2C_Slave

I2C slave library for ESP32
GNU Lesser General Public License v2.1
81 stars 20 forks source link

Guide to transition to the native I2C? #17

Closed KevinUTAT closed 2 years ago

KevinUTAT commented 2 years ago

Hi,

I am a long-time user of this library, so first I want to thank you for all your work to have I2C slave work on ESP32 all this time. I understand that the ESP32-Arduino core has finally fixed the issue with native I2C slave support. I am not very sure how would I transition to it. The fix isn't included in any release yet, should I wait for the next release? Once I have the latest Arduino core, do I just use the Wire library the same as on an Uno?

Thanks,

gutierrezps commented 2 years ago

Hi Kevin, you're welcome.

Arduino frameworks in general are developed so that, whenever possible, it's compatibility with the original API (AVR's Arduino), but there are always some hardware quirks or peculiarities. With that said, the first things you should look are the examples. A Wire slave example was added together with the changes under the hood: https://github.com/espressif/arduino-esp32/blob/master/libraries/Wire/examples/WireSlave/WireSlave.ino. You can see it's very similar to AVR Arduino examples.

At first you should wait for the next release for the I2C feature, since some fixes might be added in the meantime. But if you want to try it out right now, you can download the main branch and replace the local files that were downloaded through the development platform you're using (for example, if it's PlatformIO, the files are located by default at "C:\Users\.platformio\packages\framework-arduinoespressif32" on Windows, or "/home//.platformio/packages/framework-arduinoespressif32" on Linux I guess).

KevinUTAT commented 2 years ago

Thanks for the guide, and thanks for supporting this library for this long.

KevinUTAT commented 2 years ago

I tried the new esp32-arduino core v2.0.1rc1, so far I2C slave seems to be working