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

Thread: Setting i2c pins in teensy 4.1

  1. #1
    Junior Member
    Join Date
    Dec 2020
    Posts
    3

    Setting i2c pins in teensy 4.1

    Hi,

    quite new to Teensy. I'm trying to use an OLED display algonside the Audio Shield on a Teensy 4.1.

    I can get them to work separately, using the default SDA and SCL pins. To use them together I need to set the pins for the display elsewhere (16 and 17), but I cannot find a way to do this. The Wire library says that Wire.setSDA(pin) and Wire.setSCL(pin) work only on Teensy LC & 3.x. I tried them anyway and don't work (as expected).

    I found an i2c library for T4, but I really don't know how to replace the Wire calls in Adafruit's SSD1306 functions.

    How could I set the i2c pins to 16 and 17 in Teensy 4?

    Cheers!

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,971
    Note, I2C is a shared bus. Each I2C device has an address. This means as long as your OLED display does not use the addresses used by the audio shield (0x0a, 0x1a), you can hook the display on to the same bus. There are some gotchas if you are using higher speeds, or longer wires, but generally it should just work. Typically the SSD1306 displays use the addresses 0x3c or 0x3d.

    The Teensy 4.0 and 4.1 has a second I2C bus that you would access by using 'Wire1' instead of 'Wire'. If you are lucky, your library for the display has an option to use a separate I2C bus. If not, you would need to clone the display library, and rename the files and functions. You would manually change 'Wire' references to 'Wire1'.

  3. #3
    Junior Member
    Join Date
    Dec 2020
    Posts
    3
    Thanks a lot for your clear explanation. I was aware that multiple I2C devices can share a bus, but I was wondering if the audio wouldn't be affected since it requires very high speeds. Not sure how the protocol works though, and I guess the high-speed processing takes place in the Audio shiled, so I'll just go this way for now and try the Wire1 solution if it gives problems.

    Cheers!

  4. #4
    Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    96
    Audio to the Audio Shield goes vie I2S, not I2C, I2C is just used to control the Codec, so need to worry your Display interferes with Audio Data.

  5. #5
    Junior Member
    Join Date
    Dec 2020
    Posts
    3
    Great! Thanks!

Posting Permissions

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