I'm using i2c to have two Arduinos talk to each other using the Wiring library, and would like to determine whether they're connected at all, and display an error message if they aren't.
My problem is that currently Wire.endTransmission() hangs the master when there is no connection. Is there any way to determine whether anything is connected on the i2c bus, or to make endTransmission() timeout or make the call non-blocking?
I can't see anything in the TWI code that would hang the master (maybe someone else can?) Are you sure it hangs when there's no connection and doesn't hang when there is?
Maybe a small sample size, but I have a removable I2C DS-1307 real time clock module and if I remove it and run my sketch it does NOT hang, just returns all highs I think.
When the MD22 has power, this works fine; when it is unpowered, this prints "1\n2\n3\n", then hangs... since this project is a fairly large robot, I'd really like the main controller to never ever hang.
Can anyone enlighten me as to what might cause that hang? I looked at the Wire source, but it's fairly involved.
If the powered-down motor controller is forcing the clock line low, the master (Arduino Mega) might be sitting there forever waiting for it to go high.