I recently bout an Arduino and the MPR121 capacitive touch sensor breakout from Adafruit and i'm having a lot of trouble trying to get it to work. I loaded the MPR121test code from Adafruit to the arduino board and the only output I can get is this
"Adafruit MPR121 Capacitive Touch sensor test"
And then it just hangs. I can't get it to output anything else. Its like it's getting hung on the "cap.begin(0x5A)" line. Any help would be greatly appreciated.
MPR121 Capacitive Touch Sensor Breakout Not Working
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- thebowl92
- Posts: 1
- Joined: Fri Oct 02, 2015 1:32 pm
MPR121 Capacitive Touch Sensor Breakout Not Working
- Attachments
-
- Screenshot_9.png (4.33 KiB) Viewed 958 times
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: MPR121 Capacitive Touch Sensor Breakout Not Working
Post a photo showing your hardware and connections and we'll take a look. 800x600 images usually work best.
- JohnAutoDidact
- Posts: 1
- Joined: Wed Jan 24, 2018 3:10 pm
Re: MPR121 Capacitive Touch Sensor Breakout Not Working
I'm having the same issue. Was it resolved? The point of the code is let you know if the hardware and connections are correct or not. It should return something even if it's only the arduino with nothing connected accept the power or USB.
Code: Select all
/*********************************************************
This is a library for the MPR121 12-channel Capacitive touch sensor
Designed specifically to work with the MPR121 Breakout in the Adafruit shop
----> https://www.adafruit.com/products/
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"
// 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() {
Serial.begin(9600);
while (!Serial) { // needed to keep leonardo/micro from starting too fast!
delay(10);
}
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!
return;
// 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.println();
Serial.print("Base: ");
for (uint8_t i=0; i<12; i++) {
Serial.print(cap.baselineData(i)); Serial.print("\t");
}
Serial.println();
// put a delay so it isn't overwhelming
delay(100);
}
- benbradley
- Posts: 1
- Joined: Wed Feb 21, 2018 12:52 am
Re: MPR121 Capacitive Touch Sensor Breakout Not Working
I've had this problem (code not returning from the cap.begin call) if the breakout board is missing or not wired right. This is a little disturbing, as the code should return either way with a status of the chip working or not, and it certainly appears it was intended to do that. From a cursory look through the Adafruit_MPR121.cpp code, I don't see a problem, but it might be locking up in the wire code that it calls. Perhaps there's something else I'm doing on the Arduino that breaks it like this (my full code is in the link below).
I've got a schematic where I used four of these breakout boards in this project from a year ago. Scroll down and click on the schematic to see how I wired them up. Make sure the ground and +5V from the Arduino go to the corresponding pins (GND and VIN) on the breakout board, as well as SCL-to-SCL and SDA-to-SDA. As stated on the schematic, the pin numbers I give are for the Mega 2560 board - make sure to use the SCL and SDA pins on whatever Arduino you're using.
http://blog.freesideatlanta.org/2017/02 ... -what.html
I've got a schematic where I used four of these breakout boards in this project from a year ago. Scroll down and click on the schematic to see how I wired them up. Make sure the ground and +5V from the Arduino go to the corresponding pins (GND and VIN) on the breakout board, as well as SCL-to-SCL and SDA-to-SDA. As stated on the schematic, the pin numbers I give are for the Mega 2560 board - make sure to use the SCL and SDA pins on whatever Arduino you're using.
http://blog.freesideatlanta.org/2017/02 ... -what.html
Please be positive and constructive with your questions and comments.