Most recent activity
-
Thanks, @gordon. It's working much better now.
Baseline numbers seem stable and I am getting changes on the filtered numbers: untouched pins show 512. Touched pins values drop in the 200s range.I'll do more tests to determine the dynamic range.
I appreciate your help. -
Thanks, @Gordon.
I am getting a response from the following code using your code snippet.
I am just logging out the ouput of each MPR121 sensor pin as I run my finger over them.
Two observations: 1) the filteredData output seem to indicate which pins were touched as 2^pin. If pin 0 and pin 2 are touched, I get 2^0+2^2 = 5. I was expecting to get a value indicating the capacitance. 2) the baselineData output is 4 x the filteredData output, but not consistently.// set up I2C var i2c = new I2C(); i2c.setup({ scl : D28, sda: D29 }); // Setup pins and interface to MPR121 const sclPin = D28; const sdaPin = D29; const irqPin = D30; // interrupt from MRP121 //I2C1.setup({scl:sclPin,sda:sdaPin}); // IRQ is Active Low, open Drain (ref datasheet) - make use of internal pullup pinMode(irqPin,'input_pullup'); // connect to MRP121 via Espruino MRP121 library function mprConnected() {console.log ("MPR121 Connected");} var mpr = require("MPR121").connect(i2c, mprConnected , { address: 0x5A}); // define function for interrupt (fires on touch AND release) function readValues() { for(let i=0; i<12;i++) console.log(mpr.filteredData(i) + ", " + mpr.baselineData(i)); } mpr.readWord = function(reg) { this.write(reg); var data = this.read(2); return (data[1] << 8) || data[0]; }; mpr.readByte = function(reg) { this.write(reg); return this.read(1)[0]; }; mpr.filteredData = function(pin) { if (pin<0 || pin>=12) throw new Error("Invalid pin"); return this.readWord(0x04 + pin*2); }; mpr.baselineData = function(pin) { if (pin<0 || pin>=12) throw new Error("Invalid pin"); return this.readByte(0x1E + pin)<<2; }; setInterval(function(){ readValues(); console.log(" " +"\n"); }, 5000);
-
@Gordon: does the MPR121 module support the filtered and baseline touch values like the Adafruit MPR121 library? The functions are: filteredData(pin) and baselineData(pin).
https://github.com/adafruit/node_mpr121/blob/master/index.js
-
-
-
-
@Gordon: I have completed my tests.
Connecting wires of about 10cm drops the readings from 512 to 256.
When I touch or squeeze the wires, the values range from 5 to 256.
Results are repeatable, so for my purposes the code is working as expected.
Thanks again for your help.