Can anyone tell me how to access I2C port 3 (SCL3,SDA3) on Teensy 3.6, Wire3 does not exist.
I guess the pins could be assigned, but what if you want to use 4 I2C devices with Teensy3.6?
Can anyone tell me how to access I2C port 3 (SCL3,SDA3) on Teensy 3.6, Wire3 does not exist.
I guess the pins could be assigned, but what if you want to use 4 I2C devices with Teensy3.6?
I2C is a shared bus system. If each device has a different address, you just put them on the same bus. Each I2C device will only answer when a query is sent to that address. Many devices have solder pads or similar mechanisms to control what the address is.
If you are trying to use devices with fixed addresses that can't be changed, you can get I2C multiplexers that connect up to 8 separate I2C buses. You use an I2C command to switch which line the multiplexer is talking to.
Looking at the pinout card for the Teensy 3.6, there are 4 I2C buses:
SDA0/SCL0 -- Pins 19/18;
SDA1/SCL1 -- Pins 38/37;
SDA2/SCL2 -- Pins 4/3; (and)
SDA3/SCL3 -- Solder pads 56 and 57 underneath the Teensy.
In addition, the Teensy supports alternate pins for several of the I2C buses. You could presumably re-init the I2C bus and use the functions to change to the alternate pins between device queries. How well this works in practice, I don't know. I suspect an I2C multiplexer would be simpler to use:
Thanks Pete, yes I see that that works but I was importing the Wire library and trying to use it with Wire3 as below which produced the following error "error: 'Wire3' was not declared in this scope".
I thought that Wire was the default library to use for I2C. It is certainly the library referenced on the PJRC web site.