SerialTransfer icon indicating copy to clipboard operation
SerialTransfer copied to clipboard

Make requests to I2C slaves

Open TurboNerd95 opened this issue 4 years ago • 4 comments

Hello,

Very good job with the library. I had a lot of struggles interconnecting Arduino's when I started out and this eliminates the trouble.

I also think there should be a way for this library to incorporate the "Wire.requestFrom()" function from the Wire library, which allows a master Arduino to collect data from 1 or more I2C slave Arduino's, while also being able to transmit data to them. This would allow for 2 way communication, without the need to use multi-mastering (potentially unreliable).

TurboNerd95 avatar Jan 21 '22 18:01 TurboNerd95

Hey @TurboNerd95. Were you able to make one master multiple slaves communication? That's what I need now, and I hope there is a way to use this lib for it.

fif911 avatar Jan 22 '23 13:01 fif911

Hey @TurboNerd95. Were you able to make one master multiple slaves communication? That's what I need now, and I hope there is a way to use this lib for it.

Yes, there is an additional argument in the sendData function (targetAddress), which allows the master to send to multiple slaves:

uint8_t I2CTransfer::sendData(const uint16_t& messageLen, const uint8_t& packetID, const uint8_t& targetAddress){

However, the "request" function I was asking about doesn't seem to be implemented yet.

TurboNerd95 avatar Jan 25 '23 03:01 TurboNerd95

@TurboNerd95 Hey, thanks. I was able to discover that on the day I asked but now struggling to implement Slave to Master communication. Were you able to implement this request function somehow, or you used another solution? That's the same thing I also need now :)

fif911 avatar Jan 28 '23 09:01 fif911

@TurboNerd95 Hey, thanks. I was able to discover that on the day I asked but now struggling to implement Slave to Master communication. Were you able to implement this request function somehow, or you used another solution? That's the same thing I also need now :)

I just ended up using the basic wire.h, in order to request data from the slave's. Here is a comprehensive set of examples: https://forum.arduino.cc/t/use-i2c-for-communication-between-arduinos/653958.

TurboNerd95 avatar Jan 29 '23 06:01 TurboNerd95