I would highly appreciate if someone could point me in the direction (help with the code) to build up a simple Slave/Master communication between two arduino
What I want to do is have a communication path between few arduinos and they basically slaves take instructions from the master and report back sensor data to master via I2C bus. I'm new to I2C and have no idea where to start from.
thank you for your time in advance and Happy new Year
Take a look at the Examples in the Arduino IDE, goto File -> Examples -> Wire -> It will tell you at the top of the sketch how to use it, and which sketch to use it with.
Here's a longer example:
Here's another example code, this will will blink an LED on the Slave:
Keep in mind, the pull-up resistors are NOT required with the Arduino, it uses the internal pull-ups. Just need to connect SDA to SDA and SCL to SCL on all the devices, make SURE their grounds are connected, and you're already halfway there! :)