i need to set same device as slave in I2C1 and as master in I2C2? because arduino needs to receive data from one device and do some process in arduino sets value to other slave devices connected in I2C2
Is that possible? how could i do?
That's possible with the atmega328PB. I think there's a working Arduino core for the PB - but I don't think anyone's done anything to support the second I2C bus (I don't think it would be hard - just a copy of wire with the register names changed).
The SAMD-based Arduinos and derivatives (Zero and similar) should be able to support multiple I2C ports.
(though I don't think there are any libraries that do so in the "arduino way")
I think there's a working Arduino core for the PB
The normal 328P core works fine on the PB, but doesn't provide support for the extra peripherals. (I guess the only new peripherals that are actually part of the "core" are the 2nd Serial and the extra timers.) I2C in particular is NOT part of the core. The Atmel Xplained Mini 328PB is probably useful as a 328PB-based Arduino-compatible board.
alagappan:
could you brief explain how to implement software i2c?
Moreover i need to use existing i2c available at pin 2,3
Is it possible to use available i2c in addition with software i2c
You can find software I2C libs here:
I would recommend to make the I2C master in software and the I2C slave in hardware, because a master implementation is much easier and not time critical.
i need to set same device as slave in I2C1 and as master in I2C2? because arduino needs to receive data from one device and do some process in arduino sets value to other slave devices connected in I2C2
Is that possible? how could i do?
There is nothing stopping you from using the Arduino as both a MASTER and a SLAVE at the same time.
attached is an example Sketch. It uses 2 UNO's to read and write data to each other. This sketch requires a modified WIRE library, I implemented some timeout conditions and support unlimited onRequest datalengths.