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

Thread: AudioShield + second I2C for capacitive board MPR121

  1. #1

    AudioShield + second I2C for capacitive board MPR121


    I would like to use Teensy audio adaptor board together with Adafruit capacitive touch sensor breakout MPR121 which use also I2C as audio board.

    I've connected MPR121 to pins 29 (SCL) + 30 (SDA). Audioboard uses 18,19 for I2C.
    I don't know how to setup the MPR121 to use i2C on pins 29+30.
    I tried to change all four addresses in MPR121 test example but it can't find MPR121....

    here is the MPR121 test code:

    This is a library for the MPR121 12-channel Capacitive touch sensor
    Designed specifically to work with the MPR121 Breakout in the Adafruit shop 
    These sensors use I2C communicate, at least 2 pins are required 
    to interface
    Adafruit invests time and resources providing this open source code, 
    please support Adafruit and open-source hardware by purchasing 
    products from Adafruit!
    Written by Limor Fried/Ladyada for Adafruit Industries.  
    BSD license, all text above must be included in any redistribution
    #include <Wire.h>
    #include "Adafruit_MPR121.h"
    #ifndef _BV
    #define _BV(bit) (1 << (bit)) 
    // You can have up to 4 on one i2c bus but one is enough for testing!
    Adafruit_MPR121 cap = Adafruit_MPR121();
    // Keeps track of the last pins touched
    // so we know when buttons are 'released'
    uint16_t lasttouched = 0;
    uint16_t currtouched = 0;
    void setup() {
      while (!Serial) { // needed to keep leonardo/micro from starting too fast!
      Serial.println("Adafruit MPR121 Capacitive Touch sensor test"); 
      // Default address is 0x5A, if tied to 3.3V its 0x5B
      // If tied to SDA its 0x5C and if SCL then 0x5D
      if (!cap.begin(0x5A)) {
        Serial.println("MPR121 not found, check wiring?");
        while (1);
      Serial.println("MPR121 found!");
    void loop() {
      // Get the currently touched pads
      currtouched = cap.touched();
      for (uint8_t i=0; i<12; i++) {
        // it if *is* touched and *wasnt* touched before, alert!
        if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {
          Serial.print(i); Serial.println(" touched");
        // if it *was* touched and now *isnt*, alert!
        if (!(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) {
          Serial.print(i); Serial.println(" released");
      // reset our state
      lasttouched = currtouched;
      // comment out this line for detailed data from the sensor!
      // debugging info, what
      Serial.print("\t\t\t\t\t\t\t\t\t\t\t\t\t 0x"); Serial.println(cap.touched(), HEX);
      Serial.print("Filt: ");
      for (uint8_t i=0; i<12; i++) {
        Serial.print(cap.filteredData(i)); Serial.print("\t");
      Serial.print("Base: ");
      for (uint8_t i=0; i<12; i++) {
        Serial.print(cap.baselineData(i)); Serial.print("\t");
      // put a delay so it isn't overwhelming

    Please do you have any idea how to setup both i2c ports to use simultaneously. Probably very simple thing, but this is new for me....

    Thank you very much!!!!

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Germany NRW
    The easiest is just to use 18/19 - you know I2C is a bus?

  3. #3
    Oh, great! And does it work without any changes in the code? I've never chained i2c boards...

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Germany NRW
    Yes, it should work without any changes.

  5. #5
    Yes, it works. So it was much more easy then I expected

Posting Permissions

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