madsci1016 / Arduino-EasyTransfer

An Easy way to Transfer data between Arduinos
http://www.billporter.info/easytransfer-arduino-library/
320 stars 114 forks source link

Can slave of i2c send data to master? #9

Open khoindq opened 8 years ago

khoindq commented 8 years ago

Hi all, i would like to use i2c to send data from a slave to master, how can I achieve that, I read that using wire request can solve those problem . However I dont know how to use that with easy transfer

MG-Arnaud commented 7 years ago

Hello, I have the same problem of you and I have found a solution that I can share if someone else would do the same thing : You just have to define an adress of the MASTER, like that : Wire.begin(I2C_MASTER_ADDRESS); and you send your slave data to this adress and it's work perfectly : ET.sendData(I2C_MASTER_ADDRESS); And in your master code you wait the reception with this code if(ET.receiveData()){...}. If you have question don't hesitate. I hope that can help and sorry if my English is not very good (I am French :-D ).

P.S : I attach an example where I send data in both direction Master to slave and Slave to Master and the data have a type different (float, int, boolean) !

I2C_example_MS&SM.zip

r0oland commented 6 years ago

Thanks a lot ArnaudProjetAPP, you probably just save a few hours of my life! I think this should def. be included in the examples!

MG-Arnaud commented 6 years ago

Hello r0oland, you're welcolme :-) Thank you for your comment, it makes me happy if I could help you !