Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Teensy 4.0, use of 2 different i2c bus

  1. #1
    Junior Member
    Join Date
    Dec 2019
    Posts
    8

    Teensy 4.0, use of 2 different i2c bus

    Hello,

    Looking to switch from Teensy 3.6 to 4.0. T4(s) ordered today.


    In my T3.6 code, i use 2 i2c bus, with the i2c_t3.h library.

    When i switch Arduino software to teensy 4.0, i can't compile anymore. it's logical as the i2c_t3.h library is only for Teensy card up to 3.6... so i get a nice "Wire was not declared in this scope"...

    What is the right library to use for i2c to enjoy all the i2c ports ?

    Thanks for your help

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,114
    As far as I know, the i2c_t3 library has not been ported over to the T4.

    However the Wire library does (and has) support all of the I2C busses on all of the Teensy boards.

    But the I2C_t3 library was not developed to be 100% compatible with the Wire library.

    With Wire library, you use the Wire object to talk to the first one, Wire1, Wire2, ... for the other Wire objects.

    To use alternative pins (not sure if there are any on T4), you can do like:
    Code:
    Wire.setSCL(19);
    Wire.setSDA(18);
    But this will NOT work on T4 (however would work on T3.6 as these are Alternative pins on 3.6 for the Wire object)
    Code:
    Wire.setSCL(16);
    Wire.setSDA(17);
    Instead on T4, you would do:
    Code:
    Wire1.setSCL(16);
    Wire1.setSDA(17);
    But again these are the default and I think only pins for these two.

  3. #3
    Junior Member
    Join Date
    Dec 2019
    Posts
    8
    ok so switched back to Wire.h and it does compile, now let's wait the cards for real testing I will use Default pins.

    Thanks a lot

  4. #4
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,490
    According to the pinout chart, there are no alternate I2C pins, but there are 3 I2C buses on the Teensy 4.0:

    • Wire: Pin 19/A5 is SCL0, pin 18/A4 is SDA0;
    • Wire1: Pin 16/A2 is SCL1, pin 17/A3 is SDA1; (and)
    • Wire2: Pad (underneath the Teensy) 24/A10 is SCL2, and pad 25/A11 is SDA2.


    If your device does not have pull-up resistors, you will need a pull-up resistor between each of the 2 I2C pins for a particular bus and 3.3v. A 2.2k resistor is often the best choice for a 3.3v system for pull-up resistors.

    I recall that previous versions of Teensydunio also made Wire1, Wire2, etc. work on the other Teensy LC/3.x platforms.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •