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

Thread: probably a simple I2C question

  1. #1
    Junior Member
    Join Date
    Feb 2017
    Posts
    6

    probably a simple I2C question

    I am working on a guitar project that uses a Teensy 3.2, the audio shield, and an MPR121. The default I2C address of the MPR121 is 0x5A, but is easily changeable. Is there a strong reason to use either the same I2C bus as the audio shield or to use a second I2C bus for MPR121 (pins 29 & 30)?

    Bonus extra question - if I am using "AudioAmplifier" to set gain on L/R independently, is there any reason to use pin 15 (Volume)?

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    2,940
    Most libraries using i2c devices are written for generic Arudino chips, and assume that chip only has one i2c bus. On the AVR 328p (Uno) chip there was no option to use a second i2c bus, so most libraries don't have an option for the second bus.

    In order to use a generic i2c library on a second i2c bus, you would have to rename the library and copy to your Arduino library directory. Once you've copied the library, you would need to change all Wire references to Wire1. In addition, on the 2nd i2c bus, you would need to provide separate pull-up resistors between the SDA2/SCL2 pins and 3.3v (the audio shield provides the pull-up resistors on the main i2c bus). Similarly if you wanted to switch to the i2c_t3 library, you would have copy and rename the library, and change the Wire.h include file to i2c_t3.h.

    On an i2c bus, each device has a unique address. In general, you can have multiple devices all on the same bus, if they have different addresses.

    Since the i2c devices on the audio shield have different addresses from MPR121 (i.e. 0x0A for the SGTL5000, and 0x1A for the WM8731), you don't have to worry about changing the MPR address. You would have to change the address if you added a second MPR121 or added another device with the same address.

    Note, the Teensy 3.2 has 4 touch pins (0, 1, 16/A2, and 17/A3) that aren't used by the audio adapter, so you don't necessarily need to use the MPR121 if you want just a few touch pins. Additionally, there are 3 pads underneath the Teensy for pins 25, 32, and 33 that are also touch pins. There are 5 touch pins (15/A1, 18/A4, 19/A5, 22/A8, and 23/A9) that are used by the adapter. Unfortunately, the touchRead function is not documented in the main libraries page, so people might miss it:


    In terms of pin 15/A1, you don't have to use it if you don't want to. However, since it has extra capacitors between the pin and analog ground, you probably don't want to use it as a digital pin. But you could use it as an analog input pin for something besides volume.
    Last edited by MichaelMeissner; 02-07-2019 at 05:21 AM.

  3. #3
    Junior Member
    Join Date
    Feb 2017
    Posts
    6
    Thanks! I think I used a similar library solution when I wired the midi out on a previous guitar to a different COM port than normally specified - took a good bit of head scratching, but was ultimately functional.
    I was actually using the njhurst link to use the touchRead for slider controls, and the MPR 121 for the digital controls. I think I have a nifty control system figured out, will post more when I get it all soldered!

    Here is a video of my last Teensy guitar in action:

Posting Permissions

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