Multiple I2c Teensy 3.5

Not open for further replies.
If I understand correctly, you want read sensors connected to pins 37 (SCL1) & 38 (SDA1)?

All you need to do is replace instances of "Wire" with "Wire1": (sample code shamelessly stolen from examples)

#include <Wire.h>

void setup()

byte val = 0;

void loop()
  Wire1.beginTransmission(44); // transmit to device #44 (0x2c)
                              // device address is specified in datasheet
  Wire1.write(byte(0x00));            // sends instruction byte  
  Wire1.write(val);             // sends potentiometer value byte  
  Wire1.endTransmission();     // stop transmitting

  val++;        // increment value
  if(val == 64) // if reached 64th position (max)
    val = 0;    // start over from lowest value

Yes, exactly, just replace every "Wire" with "Wire1".

But if you're using a library which as "Wire" written deep inside its code, you would need to replace every "Wire" with "Wire1" inside that lib's code too.
I want to use scl2/sda2(3-4) and scl0 sda0 at the same time. i have a lot of sensors on board. Some of them are connected to scl0 sda0 . the others are connected to scl2 sda2. i cannot read data from scl2/sda2 but i can read from scl0/sda0. i also should read from scl2 sda2 to.
Last edited:
When a hardware specific library calls the Wire library from within you might find it useful to make a copy of the library, renaming it.

This creates a little extra work, made easier with a program like notepad++ where you may use a "find and replace" tool to sniff out references to the library and references to "Wire". Change them all - the references to Wire, and the references to the specific library everywhere they exist, even in file names.

You can then use them side by side in the same project.

This applies to SPI bus devices as well.
Not open for further replies.