Arduino-esp32: I2C Slave not implemented

Created on 5 Jan 2017  Â·  28Comments  Â·  Source: espressif/arduino-esp32

Description

It seams that the I2C slave functionality from the Arduino Wire Lib is not implemented.

Code example

#include <Wire.h> 

void setup() 
{ 
 Wire.begin(0x03);
 Wire.onRequest(requestEvent);
} 

void loop() 
{ 
 delay(10); 
} 

void requestEvent() 
{
 Wire.send(0x13);
}

Error occured during compilation

exit status 1
'class TwoWire' has no member named 'onRequest'

EDIT: Fixed errror message.

to be implemented

Most helpful comment

3-4 years after this issue is opened, nothing change?

Maybe need more people ask for this feature...

All 28 comments

did you find a solution for that issue?

no news? i've done with esp-idf but arduino way is simpler and clearer

@stickbreaker is working on slave I2C (https://github.com/stickbreaker/arduino-esp32/tree/master/libraries/Wire). Not sure where he is at with it, but development is active.

Found out  it...
many errors in compile...

Il 14/05/2018 15:14, lbernstone ha scritto:
>

@stickbreaker https://github.com/stickbreaker is working on slave
I2C
(https://github.com/stickbreaker/arduino-esp32/tree/master/libraries/Wire).
Not sure where he is at with it, but development is active.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/espressif/arduino-esp32/issues/118#issuecomment-388811729,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHSe24shLRHFJIzYM4QyD6lNilDrSxa3ks5tyYMagaJpZM4LbtDd.

--
Marco Lettieri
Head of Developments
microBees Technology Ltd

Updates?

I've got a working Slave mode, but I am still working through coexistence with Master mode. Slave mode on ESP32 has to call onRequest() before the Slave is addressed. So the outbound data is always stale. Currently Slave mode exists in a separate task, and I haven't decide on the 'correct' design to refresh this data:

  • never
  • every time onReceive() activates
  • manually controlled by application
  • every time a Master transactions supplant Slave mode.
  • so some combination of all of these.

It is base on a re-implementation of Wire() that is designed for multi-tasking support Multiple Wire() objects are create, each Object is designed as single threaded, The multiple Wire() Objects are safely multi-threaded and share the hardware. But, the Application must transactionalize their access if necessary. The transaction locking with MUTEX's can be abused to cause deadlocks. The 'simple' Arduino 'it just work' philosophy is tough to implement with complex interactions.

Chuck.

Hi @stickbreaker , Any news ?
Can you share code ?
Thanks

BUMP! Anyone have a slave receive solution/fix/workaround?

BUMP! Surely there must be enough demand for this feature to warrant some serious development from those that know how?

Update? How can we help?

Any Update This issues?
I'd like to use I2C Slave mode with arduino uno

@JAICHANGPARK i2c slave does work on the Arduino Uno. This issue is for ESP32.

@ameer1234567890 I already know.
I mean that I hope to use Esp 32 Slave Mode using arduino IDE

Any updates? Or example how to workaround that issue?

Please help, I also need to use an ESP32 in slave mode but get this error:
(.literal._Z5setupv+0x8): undefined reference to `TwoWire::onReceive(void (*)(int))'

@Tom5051 @yeckel No updates yet, I have a proof of concept, but it is not ready for prime time, (It requires a major change of existing code). Possibly Spring 2020 I might have code is releasable.

Chuck.

Thanks for your efforts Chuck. Another bump for i2c as a slave mode when you have a chance. Would be really useful.

@netkruzer Not ready yet. It's not yet code that I want my name attached to. And, I do not want to even think of supporting it as is.

Chuck.

Darn, I'm also wanting this feature..

@stickbreaker Hi Chuck. Any date in the foreseeable future that you can provide to have a release of the I2C solution for ESP32? I have been dreaming for a while to use it for some projects I have. Let us know!

Thanks
-zamorae

It was reported on #1697 by @laercionit that "Someone had succeeded in putting as SLAVE?" Any details on this?

I couldn't ... I don't think TwoWire is ready for that.

I have made a workaround library not based on interrupts, but based on the only two slave methods currently available from ESP-IDF.

https://github.com/gutierrezps/ESP32_I2C_Slave

@gutierrezps
How to use your library in ESP32(slave) communication with RasPi(master) ?
May you give an example of a compatible Python script ?

@sgrd I'm sorry, but I don't work with Raspberry Pi's at the moment, so I'm afraid I can't help you. You can look into WireSlaveRequest and try to map Arduino functions into the Raspberry's functions.

3-4 years after this issue is opened, nothing change?

Maybe need more people ask for this feature...

Any updates?

It would be nice to have an arduino master and an Esp32 slave to get I²C communication into home assistant.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lonerzzz picture lonerzzz  Â·  3Comments

docloulou picture docloulou  Â·  3Comments

maxgerhardt picture maxgerhardt  Â·  3Comments

huming2207 picture huming2207  Â·  4Comments

mistergreen picture mistergreen  Â·  4Comments