MPR121 Touch Sensor Breakout Demo Error

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
yishi
 
Posts: 16
Joined: Fri Jan 31, 2014 12:10 am

MPR121 Touch Sensor Breakout Demo Error

Post by yishi »

Hi,

I'm trying to use this sensor with Arduino Due but got stuck at the first step.

I got an error when compiling:

MPR121test.ino: In function 'void loop()':
MPR121test.ino:52:29: error: '_BV' was not declared in this scope
MPR121test.ino:56:30: error: '_BV' was not declared in this scope
Error compiling.

Please help!

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: MPR121 Touch Sensor Breakout Demo Error

Post by adafruit_support_mike »

That looks like a platform error.

The Due uses a different microcontroller than the rest of the Arduino family, so it takes some massaging to get code written for the Uno to compile for a Due.

IIRC, that error has something to do with the Wire library, which handles I2C. Let me check with our Due expert to see if he knows more about that library.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: MPR121 Touch Sensor Breakout Demo Error

Post by adafruit_support_rick »

_BV is a macro in the AVR library. It doesn't exist in the ARM library, so you have to provide it. Add the following to your sketch, right after the #includes:

Code: Select all

#ifndef _BV
  #define _BV(bit) (1<<(bit))
#endif

User avatar
yishi
 
Posts: 16
Joined: Fri Jan 31, 2014 12:10 am

Re: MPR121 Touch Sensor Breakout Demo Error

Post by yishi »

Thanks guys!

Now I'm able to run the sketch.

However, the Serial shows another error:

Adafruit MPR121 Capacitive Touch sensor test
MPR121 not found, check wiring?

I think my wiring is correct.

SCL to 21(SCL) on Due
SDA to 20(SDA) on Due
Vin to 5V on Due
GND to GND on Due

User avatar
yishi
 
Posts: 16
Joined: Fri Jan 31, 2014 12:10 am

Re: MPR121 Touch Sensor Breakout Demo Error

Post by yishi »

I need to use this chip with Arduino Due.

But I just tried it with Leonardo got some other issues.

The program seems to be stuck at !cap.begin(0x5A)

The Serial only says "Adafruit MPR121 Capacitive Touch sensor test" and not even "MPR121 not found, check wiring?"

I have no idea what's going on...

User avatar
yishi
 
Posts: 16
Joined: Fri Jan 31, 2014 12:10 am

Re: MPR121 Touch Sensor Breakout Demo Error

Post by yishi »

Now the chip works with Leonardo finally. I think it was caused by bad soldering.

But it still doens't work with Due, it keeping saying can't find the chip.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: MPR121 Touch Sensor Breakout Demo Error

Post by adafruit_support_rick »

I don't know what to tell you. There's nothing about the Due that would make it not work. If it works with a Leonardo, it should work with a Due.

User avatar
yishi
 
Posts: 16
Joined: Fri Jan 31, 2014 12:10 am

Re: MPR121 Touch Sensor Breakout Demo Error

Post by yishi »

Hi Rick,

I tried with two different Due and it still can't find MPR121.

Is there any issues with Due's I2C communication you know of?

I found this post http://forum.arduino.cc/index.php?topic=146802.0 saying there are something wrong with Due's I2C. But understanding the post is beyond me. Some of them saying replace Wire.cpp would fix the I2C bug, but I tried and only got compile errors.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: MPR121 Touch Sensor Breakout Demo Error

Post by adafruit_support_rick »

Try this version of the library. Delete the old version.
Connect your MPR to SDA1 and SCL1 (in the upper left, near digital 13)
Attachments
Adafruit_MPR121.zip
(38.7 KiB) Downloaded 259 times

User avatar
erikbrandl
 
Posts: 1
Joined: Mon Jun 20, 2016 2:31 pm

Re: MPR121 Touch Sensor Breakout Demo Error

Post by erikbrandl »

Hi Rick,
Is there any news about the Problem?
I have the same Problem as yishi and your library didn`t solve it...

I have the shield as well as the breakout Mpr121, I tried on an uno and both worked. Just the due makes problems.
It gives me :

Adafruit MPR121 Capacitive Touch sensor test
MPR121 not found, check wiring?

Any suggestions?
Thanks alot!
erik

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: MPR121 Touch Sensor Breakout Demo Error

Post by adafruit_support_rick »

Have you updated to the latest board support package for the Due?
You're using SCL1 and SDA1 for the I2C connection?

User avatar
baynesstua
 
Posts: 3
Joined: Thu Mar 22, 2018 7:01 pm

Re: MPR121 Touch Sensor Breakout Demo Error

Post by baynesstua »

adafruit_support_rick wrote:Try this version of the library. Delete the old version.
Connect your MPR to SDA1 and SCL1 (in the upper left, near digital 13)
Hi, I have the exact same issue and have used this solution, but is still not fixed. Is there any update to this problem? Any solution would be much appreciated!. Thanks

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: MPR121 Touch Sensor Breakout Demo Error

Post by adafruit_support_rick »

Did you download and install the zipped version of the library, posted above?

As far as I know, the MPR121 works with the Due

I don't have one to test with here. I can get one and try it out.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”