Sending struct via I2C

Hi guys,

I've got 2 Arduinos and I want them to communicate with each other over I2C. With using the example code I can send a byte from the slave to the master. Is it possible to send a struct via I2C to the master?

The wire reference says "Wire.send(data, quantity)", but data needs to be the datatype byte. I thought about converting the struct to a array of bytes and send it... but how can I convert the byte array back to a struct?

I also tried google, but it didn't helb :frowning:

Cheers!

Bill Porter's site has a library (EasyTransfer) where he shows sending and receiving a structure via a serial link. As serial is also a byte at a time transfer, perhaps you could adapt/convert his code to use I2C?

Lefty

RS232 and I2C send one bit at a time and 8 bit work to send a byte so multiple bytes will just work .

Read the tutorial - Wire - Arduino Reference - and you see that you can send strings etc

for structs you need - Wire.send(data, quantity) -