Wire Library, Wire.begin  Documentation

It seems the Wire.begin() procedure is intended to be called only once, usually in setup(). I found out the hard way it bombs if you keep calling it, though it does not complain.

Could we update the documentation to:

Description: Initiate the Wire library and join the I2C bus as a master or slave. This should normally be called only once.

Yeah, never call Wire.begin() more than once, it allocates 160bytes of memory every time.

I think the code should cover for that case.

Fixed.

I am unclear as to whether each device on the bus requires a 'Wire.begin()', with the addresses filled in for the slave/remote devices.

I am currently using the DS1307 RTC (on the Adafruit Data Logger Shield) as the only device on the bus. I wish to add a 24LS256 Memory chip.

Thanks!

The Wire.begin() should only be called once - it initializes the wire library.

You will need to address each of your slave devices just before you talk to it using wire.beginTransmission(Address). Then you use wire.send() to queue up the message data and wire.endTransmission to initiate the sending.

Thanks Mike!

That looked to be the case, but I couldn't seem to locate any existing code using more than 1 device.

The () after Wire.begin led me to think that there was more to it.

Hope to be writing bytes to the chip this evening. :slight_smile: