
#include // Library for I2C communication The other library imports wire.h automatically. *When using the latest version of the LiquidCrystal_I2C library it is no longer needed to include the wire.h library in your sketch. In the rest of this tutorial, I will cover more of the built-in functions of this library. As mentioned earlier we need both the wire.h* and the LiquidCrystal_I2C library. While (Wire.First, the required libraries are included.

Wire.requestFrom(8, 6) // request 6 bytes from slave device #8 Serial.begin(9600) // start serial for output Wire.begin() // join i2c bus (address optional for master) This example code is in the public domain. Refer to the "Wire Slave Sender" example for use with this Reads data from an I2C/TWI slave device slave is just to send 6 bytes ("Hello ") to master when prompted. Here is the code which is just copy pasted from Wire library examples ( master reader for master arduino and slave sender for slave arduino.

Master sends data seamlessly ( although here master is just reading but i was able to send data from master to slave successfully) but when master requests data from slave it does not get desired response. i have assessed that problem is in requestEvent function of slave as that either doesnt send anything. Problem only appears when master requests data from another arduino slave (master sends data successfully to slave arduino but vice versa is not true).

Definitely there is something wrong with my approach. Unable to do what i was upto i resorted to example sketches of Wire library to assess what i was doing wrong and to my surprise even example sketches were not working. I am not able to receive bytes from slave arduino. then i wanted to establish i2c communication between 2 arduinos such that both exchange each other's sensors data. I tried i2c EPROM and that worked pretty fine with arduino master.
