Electronic – Arduino I2C communication between 2 master networks

arduinoi2c

I have 2 Arduino microcontrollers, each with a network of I2C devices connected to them (one has 2 ADCs and the other an LCD display and a RTC). How can I use the I2C connection to transfer the values obtained by the first uC from the ADCs to the second ? Both uC are masters on their I2C busses.
I was thinking of making a software I2C on the second uC and connect it as a slave to the first one (so the second controller would have 2 I2C ports: one hardware and one software). Problem is, I can't find any software I2C library that works as a slave. All are masters.

Waiting for your ideas.


Question is, can I make 2 I2c networks using one Arduino Mega2560 ? One as master on the hardware port to communicate with the LCD and the RTC and one as a slave on a software port on 2 other pair of pins (for SCL and SDA) for receiving data from another master arduino…


After analyzing all the data, I reach the conclusion that the 2 I2C busses cannot be linked together. On the external I2C port I have available on the data acquisition uC, I will connect another arduino as slave that will receive the information an pass it on by using a wireless adapter (probably a NRF24N01). That way, I don't need to have wires from my solar controller to the arduino that reports the production to pvoutput website.

Best Answer

From the comments you want to be able to connect only to the I2C bus on each of your separate projects and transfer data.

Wirning lets you run an Arduino as either an I2C Master or a Slave. You can't run both the master and slave Wiring software on a single micro since they both want to use the USI hardware, but since you only have one USI, you can connect to only one bus anyway.

I'd suggest an effective way would be to use an ATTiny85 as a I2C slave interface on each bus and then connect them together via a software UART. There is a very nice TinyWire library available for ATTiny85 from Adafruit....they also have a very small board called the Trinket too that you could use.

There are a bunch of ATTiny85 boards (like Digispark) available that can hook up to the Arduino programming environment so this should be a simple and cheap way to create an I2C slave.

While some may say this is overkill, it would be extremely simple to implement and would not require any hardware mods to your project.