Teensy 4.1 and Wire2 (I2C comms issue)

mmdo

Member
Hello,

I am working on a project that uses the SDA2 and SCL2 pins on the Teensy 4.1. I've read a lot of forum posts where people have apparently been able to do this, as long as they make use of Wire2 instead of Wire with the Wire.h library. I am still having trouble though. I can't get the I2C writes to work on Wire2. I'm using Platform IO with arduino framework. Here is what I know:

  • When I use Wire (pins 18/19) I can see the I2C writes on the pins correctly with a scope.
  • When I use Wire2 (pins 24/25), I don't see the writes, in fact pin 25 is output low while 24 is constant 3.3V. Still compiles though.
  • When I right click and go to definition on Wire2, it takes me to i2c_t3.cpp, which I can google and see that this is not meant for teensy4 and higher.
  • Yes, I have pull up resistors on my I2C bus in both cases

How are people having success if i2c_t3 is not for the 4.x devices?

I'm not sure what to provide, since it doesn't seem like this is a problem with my code (works correctly on Wire). It seems like my knowledge on setting up a project properly in platform IO may be limiting here?

Thanks,

Code:
#include <Arduino.h>
#include <Wire.h>

// Hardware Pins
#define SDA     25    // I2C
#define SCL     24

void setup() 
{
  Wire2.begin();
  Serial.begin(9600);
}

void loop() 
{
  Wire2.beginTransmission(0b1100100);
  Wire2.write(0b00001111);
  Wire2.write(0b11111100);
  Wire2.endTransmission();
  delay(1000);
}
 
I use PlatformIO too and have no problem using Wire2.

I would suggest that you check your wiring. The pin immediately above 24 is 3V3 and from your description it seems you may just be "off by one"
 
I just checked and the actual definition of Wire/Wire1/Wire2 for T4.1 is in WireIMXRT.cpp & WireIMXRT.h which is conditionally included from Wire.h
Code:
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
#include "WireIMXRT.h"
 
Thanks thebigg for the response.

I am probing directly off the pin next to the silkscreen 24/25 on the Teensy, so I don't think I'm accidentally measuring the 3.3V.

Since I am apparently getting the wrong definitions for Wire2, maybe I need to re-create this project and see if some configuration is messed up

Thanks again
 
How are people having success if i2c_t3 is not for the 4.x devices?

Please be advised that i2c_t3 does not work with Teensy 4.x devices. The author has not updated the library for Teensy 4 so only works with Teensy 3.x devices. You will have to change that to use the Wire library.
 
I've tried reinstalling platform io and recompiling, but I continually get brought to i2c_t3 when I go to definition on wire2. Anyone know why this might be?
 
I've tried reinstalling platform io and recompiling, but I continually get brought to i2c_t3 when I go to definition on wire2. Anyone know why this might be?
I have learned not to rely too much on Microsoft Intellisense. In my experience it gets it right maybe 95% of the time but sometimes gets it obviously wrong. In the end the only thing that matters is gcc finding the right headers.
 
Back
Top