bareconductive / mpr121 Goto Github PK
View Code? Open in Web Editor NEWBare Conductive MPR121 Arduino Library
License: MIT License
Bare Conductive MPR121 Arduino Library
License: MIT License
Hi is it possible to measure a value corresponding how far the finger is near the sensor?
I have different pads that varies in size and how far they are placed behind the surface which can be touched. So I would like to analyze the different values
Hi all!
In my test an error appeared.
Hardware and software configuration:
Arduino nano (Chinese)
SSD1306 display (address: 0X3C) : https://github.com/adafruit/Adafruit_SSD1306
MPR121 (address: 0X5A): https://github.com/BareConductive/mpr121
The SSD1306 and the MPR121 are on same I2C bus (A4, A5).
After I upload and try to run the sketch, it's stopping at initializing the SSD1306.
Error message: SSD1306 allocation failed
I ran an I2C scanner, and the results is was ok, I saw all two addresses.
I only mixed two sketch examples into one code.
If I try to run ONLY an example sketch of MPR121 OR SSD1306 everything is OK.
So, I think it's not a hardware mistake.
It's seems after the MPR121 library starts, anything sets to wrong about the I2C wire library.
With other SSD1306 libraries (for example: SSD1306 ASCII) the problem isn't appeared.
But the Adafruit library will be better for this work.
I tried this hardware config with Adafruit_SSD1306 library + SHT20 sensor (with DFRobot_SHT20 library) and there was no problem.
What can I check at MPR121 to solving this issue?
When searching for MPR121 libraries in Arduino, it only links to a different library (https://github.com/janelia-arduino/MPR121) but not to this one.
The readme here suggests that it should be available in the library manager.
Hi
I want to change sensitivity more sensitive.
How can I change the sensitivity??
As stated in PR #6 the constructor of MPR121_t may crash. (PR #6 states this for ESP8266, but the issue is valid generally).
The C++ standard gives no information about initialization order of global or static objects in different compilation units.
However, the MPR121 object is global, so the constructor is called at startup (before main()
, so before arduino's setup()
). The constructor then calls Wire.begin()
, but there is no guarantee that the global Wire
object has been constructed yet.
Solutions:
a) Lower initialization priority of MPR121 by using the gcc-extension __attribute__ ((init_priority (*prio*)))
b) Increase initialization priority of Wire (must be done in the Arduino library)
c) Don't reference any objects that do not belong to MPR121_t in the constructor.
For now I would prefer solution c), because there is no real need to call Wire.begin()
. People should call Wire.begin()
in their own setup()
-code.
Background:
The problem with this issue is that it is caused by undefined behavior. Odds are good that the current sources compile and run fine without any problems, because Wire will be constructed before MPR121. However, subtle changes somewhere else in the code can change the construction order and lead to the problem. In my case it seems that a changes somewhere in the arduino framework triggered the problem.
I've just discovered tonight both doing an update from Stretch to Buster on once working python3 import MPR121 and from a fresh install on a completely different Pi and PiCap that import MPR121 errors out only in Python3. Python2.7 works fine.
Also confirmed with all the latest update on Stretch system that Python3 import MPR121 still works.
Error:
XXXXX:~ $ python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import MPR121
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'MPR121'
Hi
can u compile it on Esp32 if give some error not esp32 Compatible .
please help if you can
thanks
Hi,
is it possbile to Control 2 MPR121 Boards with different I2C Adresses?
i need 24 Touch Inputs and therefor one MPR121 Board isn´t enough...
Thanks for your Reply!
Flo
When trying to add the library to the Arduino IDE I get told that "invalid library file is found".
Help would be much appreciated.
I noticed that you do override some of the default configurations and it resulted in a +- 120 micro amps power consumption on waiting for any new input. Since I use the sensor for battery driven water level sensing, I cannot afford this much power consumption.
The reason for this much power consumption I found is the setting of AFE2 register. By default it samples every 16ms, but you configure it to be 1ms. When I changed the value of the register to 0x34 the response time was still great, but power consumption went down to a non measurable level. My meter showed 0.001 milliamps usage for both the Atmega328p in deepsleep and the MPR121 measuring.
Honestly the library works great (much better than the adafruit one) but it would be great if you could add a simple method to change the default sampling interval.
Thanks for you hard work.
Regards,
Wesley
Hi,
I'm currently using this library on an ESP8266 and just noticed the most recent change from a couple weeks ago talks about EEPROM (I've not read the changes yet, just lightly skimmed).
So, basically the library currently works on ESP8266, so you know if that has change with the recent update?
Thanks for the work!
Hi,
First of all, I would like to thank you guys for the library. It works like a charm !
I have a custom MPR121 user interface board and want to implement the proximity detection feature.
I tried the "DataStream" example but the 13th electrode reads 0 every time.
So if we could have a dedicated proximity detection example to explore this feature, that would be great.
Regards,
Sumant
Would be nice to make it compatible with the new Arduino boards
I used it like this. But input (touch sense) does not respond and output works fine as per the code in mpr 121.
MPR121.setNumDigPins(3);
MPR121.pinMode(11, OUTPUT);
if (MPR121.touchStatusChanged()) {
MPR121.updateTouchData();
for (int i = 0; i < numElectrodes; i++) {
if (MPR121.isNewTouch(i)) {
if (i == 9) {
digitalWrite(load2,HIGH);
}
if (Power == 0) {
MPR121.digitalWrite(11,load1);
}
Readme calls out the feature "Separate touch and release trip thresholds for each electrode"
I don't see any examples on simpletouch.ino how to address individual electrode thresholds, only overall thresholds with:
MPR121.setTouchThreshold(40);
Thanks in advance for any insight.
Thank you for your tutorials and for this library, it has really been helpful for me.
However I have a question. I have read through the examples and the source code of the library, and this was not very clear to me and it is important in my application.
Please I will like to know the charge discharge current (CDC) for the electrodes, also the charge discharge time (CDT).
I understand from the source code the CDC is auto set, is there a way I can have this values displayed? Same also for CDT, is there a way I can display the values?
i can't use this library with esp32
In the file "MPR121.cpp" in the function getRegister(), there is a Wire.endTransmission() directly after a Wire.requestFrom().
The Wire.endTransmission() should only be used when writing data and only in combination with Wire.beginTransmission() and almost always with Wire.write().
To test if valid data was received, the return value could be used, as is done in the other functions. However the function getRegister() can not return a 'false' like the other function.
This is not okay:
Wire.requestFrom(address,(unsigned char)1); // just a single byte
if(Wire.endTransmission()!=0){
error |= 1<<ADDRESS_UNKNOWN_BIT;
} else {
error &= ~(1<<ADDRESS_UNKNOWN_BIT);
}
scratch = Wire.read();
Perhaps this is better:
if(Wire.requestFrom(address,(unsigned char)1) == 1){ // just a single byte
error &= ~(1<<ADDRESS_UNKNOWN_BIT);
scratch = Wire.read();
} else {
error |= 1<<ADDRESS_UNKNOWN_BIT;
}
But I'm not sure if that is how you want to deal with an error.
The case handling of the case CAL_LOCK_ENABLED_10_BIT_COPY
in the function void MPR121_type::setCalibrationLock(mpr121_cal_lock_type lock)
does set the bits for ELEPROX_EN
instead of CL
.
Currently bits are set like this:
ECR_backup |= (3<<4);
But shouldn't it be the following:
ECR_backup |= (3<<6);
Hi,
i love your library!
it tried with 3 different WS2812b LED Librarys, but it doesnt work with them...
(Fastled, Adafruit_Neopixel, Easyneopixels)
i can initialize the LEDs in setup{} and everything works, but when i try to change the LEDs in void{} the don´t respond anymore..
do you have a solution for that?
Thanks a lot!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.