0
\$\begingroup\$

I'm relative new to electrical engineering, so this might be a obvious question. I'm trying to allow two arduinos to communicate with one i2c sensor. One of the arduinos is deeply integrated within the system and on the same i2c bus as the sensor, while the other one is just a standalone arduino only used occasionally for debugging and data collection and is not on the same i2c bus.

I guess I'm looking for a IC that can switch between the two devices so that it can isolate the sensor and form a i2c bus with the second arduino when needed, and switch back to the other i2c bus otherwise.

Thanks!

\$\endgroup\$
  • \$\begingroup\$ you do not need an IC .... all you need is a DPDT switch \$\endgroup\$ – jsotola Feb 18 at 5:50
  • \$\begingroup\$ thanks for the reply, but i would like to do the switching via software \$\endgroup\$ – Jerry Miao Feb 18 at 5:51
  • \$\begingroup\$ a guess is there a equivalent to a DPDT switch in ic is a better question? \$\endgroup\$ – Jerry Miao Feb 18 at 5:54
  • \$\begingroup\$ Hold the first Arduino in Reset when you plug the second one in. then the second one is the master. \$\endgroup\$ – Jack Creasey Feb 18 at 6:14
  • \$\begingroup\$ With 2 power sources even if floating ,you are likely to experience EMI problems from SMPS leakage ripple asa common mode noise on I2C which is fairly high impedance and not very robust. So good luck and consult with someone with EMI system noise experience to shunt CM noise. without a block diagram , wiring method , I cannot guess, but I would expect some CM noise interference. \$\endgroup\$ – Sunnyskyguy EE75 Feb 18 at 6:21
0
\$\begingroup\$

I would suggest using a tri-state gate. A tri-state gate is a digital logic device (available in IC form) that basically allows you to disconnect a circuit element from a circuit electronically. In other words, the tri-state gate is much like a mechanical switch, but instead of flipping the switch, you control the gate with an electronic control signal, like an arduino pin output. When the arduino output is off, the tri-state gate is open, meaning that it looks like a break in your circuit. When the arduino input in on, the tri-state gate looks like a buffer, allowing digital 1's and 0's to pass unimpeded. Google these devices to find an IC that suits your needs, and from there learn the specifics of the device you've selected.

\$\endgroup\$
0
\$\begingroup\$

As other stated it is possible to achive your desire result using a mechanical swith or whatever. But there is another way(if you can change the code in both Arduinos). By nature I2C is a master/slave bus, but it is posible to apply a multimaster i2c protocol. All the necesarry hardware already exist in the Atmega I2C peripherial. You can search in github for an arduino library with i2c multimaster capability. Since the i2c bus consist of two lines pulled up by resister and arbitraryly pulled down by the interventors it's electricaly safe. You won't burn any Arduino as long as you don't put the connected pins as OUTPUT and drive them HIGH. If the communication between the first Arduino and the sensor is not that often(ten times a second or less), you can sense the clock line with the debuging Arduino(just connect any pin and digital read, or add an interrupt), so you wait for a transfer to ocurr in the bus, then wait a couple miliseconds and with the debugArduino as a master, make a data request form the sensor. The other Arduino won't be afected at all and won't see anything. The worst case is a comunication collision in which none of the Arduino won't comunicate (that's why I suggest you to check the clk line). All this is posible beacue of the nature of the i2c bus. i2c schematic from Wikipedia

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.