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

Thread: teensy 3.6 using A18,A19 as I2C along with audio shield

  1. #1
    Junior Member
    Join Date
    Oct 2016
    Posts
    14

    teensy 3.6 using A18,A19 as I2C along with audio shield

    I am using A18,A19 on teensy 3.6 as I2C to drive another module along with the teensy audio shield(I think A4,A5 are reserved for the audio shield). I am using i2c_t3.h since my assumption is that the wire.h library would only allow one I2C module being driven. However, after I add <i2c_t3.h> or replace <wire.h> with <i2c_t3.h>, I start to receive compiling errors like "Wire.cpp:507: multiple definition of `Wire'" and "Wire.cpp:376: multiple definition of `i2c0_isr'".

    May I ask if there is a way to use other i2c pins(A18,A19) as the audio shield is used?

    I also attached a mic-check script and the code used to drive the other I2C device(a SparkFun FM module si4703) in case they are useful. All I want is to use the line-in of the audio shield to take audio frequency analog output from the FM module.

    Thanks~

    miccheck.ino fm.ino
    Last edited by lazybaby7; 11-26-2016 at 01:52 AM.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,050
    Quote Originally Posted by lazybaby7 View Post
    I am using i2c_t3.h since my assumption is that the wire.h library would only allow one I2C module being driven.
    Wire works fine with multiple I2C devices, as long as each use its own unique I2C address.

  3. #3
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,887
    Quote Originally Posted by lazybaby7 View Post
    May I ask if there is a way to use other i2c pins(A18,A19) as the audio shield is used?
    I believe the Audio shield uses pins 18 and 19 as a normal i2c bus. As long as you don't use i2c devices with address 0xA and 0x1A, it should be fine to add more devices to the i2c bus. The schematic for the Audio shield shows that both pins 18 and 19 have 2.2K pull-up resistors, so you won't need to add extra resistors.

    As you've discovered, if you use the i2c_t3 library, you have to go through all libraries, and change them to use i2c_t3. This would mean you can access the other 3 i2c buses on the Teensy 3.6 easily.

  4. #4
    Junior Member
    Join Date
    Oct 2016
    Posts
    14
    Hello Paul Stoffregen, are you suggesting I should use A4,A5 or I should be able to use A18,A19 with <wire.h>? If the latter one is the answer, may I ask if there are similar things as Wire1.begin() in <Wire.h> since A18 and A19 does not work proporely after I use wire.setSDA(A19) and wire.setSCL(A18). Thanks.

  5. #5
    Junior Member
    Join Date
    Oct 2016
    Posts
    14
    Hello Michael Meissner. Thanks for you comments. You are right, looks like i2c_t3 is a superset of wire.h. Probably I should have gone through the audio library.

  6. #6
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,917
    Quote Originally Posted by lazybaby7 View Post
    Hello Paul Stoffregen, are you suggesting I should use A4,A5 or I should be able to use A18,A19 with <wire.h>? If the latter one is the answer, may I ask if there are similar things as Wire1.begin() in <Wire.h> since A18 and A19 does not work proporely after I use wire.setSDA(A19) and wire.setSCL(A18). Thanks.
    I don't believe A18/A19 will work with wire.h and as you mentioned wire.setSDA(A18) will not work as A18 is on SDA1.

    Currently only I2CT3 supports wire1... At one point I was building a version of wire.h which includes all of the busses, but never completed it.

    Again I wish we would set up a way to make these two libraries would work better with each other. I know that there were some proposed hacks to allow you to mix. I don't remember too many of the details, but what I thought about trying was to maybe:

    Create my own version of the wire library, where I put it into my <arduino sketch>/libraries folder, which more or less does nothing (but maybe include i2c_t3.h. And then lets the I2C_t3 library work, with the options. This might work as long as there are no libraries that use some of the interface differences like: wire.setSDA or wire.setSCL...

  7. #7
    Member javiernicola's Avatar
    Join Date
    Apr 2018
    Location
    Madrid
    Posts
    20
    I have the same problem.
    Im using the Audio shield and i need to turn the board into a slave_i2c device for external coms.
    For doing this i use the "i2c_t3" library and change the pins to I2C_PINS_37_38.

    When i try to compile i get errors like:
    Code:
    conflicting declaration 'TwoWire Wire'
    
     extern TwoWire Wire;
    
    previous declaration as 'i2c_t3 Wire'
    
     extern i2c_t3 Wire;
    
    
    conflicting declaration 'TwoWire Wire1'
    
     extern TwoWire Wire1;

    I dont know what to do, should i dive inside audio.h and try to change the i2c config from using wire.h to using i2c_t3?

  8. #8
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,593
    you can't use both wire.h and i2c_t3.h in the same sketch. wire.h supports Wire1 (pins 37, 38), e.g. Wire1.begin()

  9. #9
    Member javiernicola's Avatar
    Join Date
    Apr 2018
    Location
    Madrid
    Posts
    20
    You were absolutely right manitou, Wire1 does support those pins.


    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
  •