Go Down

Topic: arduino as I2C slave communicate with sensor? (Read 1 time) previous topic - next topic

Mike M

I'm using an arduino acting as a slave on an i2c bus request bytes from a i2c sensor that is also a slave?

In my case the arduino is talking to a Lego NXT (which must be set as the master) and the sensor is a three axis magnetometer.

I could have the NXT read the magnetometer and relay it to the arduino, but that would be pretty slow.

BenF

Quote
I'm using an arduino acting as a slave on an i2c bus request bytes from a i2c sensor that is also a slave?

If the question is, whether a single Arduino can act both as master and slave on the same bus, the answer is - yes. Just call the approriate functions in the wire library and you become a slave, master or both.

Mike M

I'm still a bit confused.  If the arduino acts as a master and and a slave at the same time.  Does the master NXT set the clock for the arduino and the arduino set the clock for the i2c sensor?

BenF

Quote
Does the master NXT set the clock for the arduino and the arduino set the clock for the i2c sensor?

Yes - that is the way it works. Support for multiple masters, including bus arbitration is part of the I2C specification.

There may be potential issues however if two masters try to read from the same sensor simultaneusly. This is not due to limitations in the I2C protocol, but the Arduino Wire library.

Go Up