You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
it looks like not possible to directly use TwoWire in slave mode. in this case the rxbuffer is never fill.
There is a différence in having an empty user receive handler and not having a receive handler. In the first case rxbuffer is fill correctly in the second case it is not fill.
Having: TwoWire myI2C(PB7, PB6);
setup: myI2C.begin(0x18) ;
in this case myI2C.available() is never > 0.
to have myI2C.available() > 0 when a message is received you must have implemented: myI2C.onReceive(onReceiveHandler);
onReceiveHandler may be an empty code {}
in this situation TwoWire works correctly.
To Reproduce TwoWire myI2C(PB7, PB6);
setup: myI2C.begin(0x18) ;
loop:
Activity
fpistm commentedon Mar 23, 2026
Hi @camelator
I don't see the issue you have to provide the receive handler/event function.
https://docs.arduino.cc/language-reference/en/functions/communication/wire/onReceive/
You can also see the example:
Arduino_Core_STM32/libraries/Wire/examples/slave_receiver/slave_receiver.ino
Line 18 in 93d2c96