Hello,
When running Adafruit's sketch to debug MPR121's "raw" data using cap.filteredData(i) & cap.baselineData(i), everything works just fine if using an Arduino UNO or an Arduino MEGA. When running it on a HUZZAH32, the filtered data keeps returning wild readings (65535, 32738, etc.) on several (not all, but almost never none) of the cap sensors. The HUZZAH32 is connected via USB to my laptop (same as the tests on the Arduinos). I2C ports on HUZZAH are 23 for SDA & 22 for SCL. I ran other sample programs (not involving MPR121) on the HUZZAH32 and it works fine (so the board is ok).
A brief sample of the monitor output from the 12 sensors´ filtered and base data looks like this:
Filt: 227 216 198 195 195 189 65535 205 65535 65535 65535 32738
Base: 224 216 196 192 192 188 212 1020 196 604 180 196
0x0
Filt: 65535 65535 197 195 65535 189 65535 205 65535 185 181 197
Base: 624 216 196 192 192 188 212 204 1020 184 180 196
0x0
Filt: 228 216 197 196 195 189 214 205 196 185 182 197
Base: 224 212 1020 192 1020 188 212 204 196 184 180 196
0x0
If I grab (i.e. touch) the USB cable feeding the HUZZAH32, all sensors go wild (it does not happen with the Arduinos), so there is clearly some issue with noise from the power line feeding the HUZZAH32. I tried with different USB cables with the same result.
Has anyone seen noise from the power line in the HUZZAH32 fed into the 12C channel? Or into the cap sensors of a MPR121?
Since I intend (eventually) to make this a wireless cap sensing solution (hence the need for a HUZZAH32), there won't be a USB cable. It will all be fed by a 1200mAh LiPO battery which may solve the noise problem from the power line. But, since there's is still a lot of coding ahead of this project, I'll need the USB tether.
Thinking it could be an speed compatibility issue (given the speed differences between Arduinos and HUZZAH32), I tested several clock speeds on the I2C channel (from 5k to 400k), changed crystal speed on the HUZZAH32 to 40MHz and 80MHZ, and added delays of up to 1 sec between readings, but got the same results (only slower, or faster).
Thanks in advance for any insights!
#include <Wire.h>
#include "Adafruit_MPR121.h"
#ifndef _BV
#define _BV(bit) (1 << (bit))
#endif
Adafruit_MPR121 cap1 = Adafruit_MPR121();
void setup() {
Serial.begin(115200);
Serial.println("MPR121");
if (!cap1.begin(0x5A)) {Serial.println("5A Bad"); while (1); }
else {Serial.println("5A Good"); }
Wire.begin (23, 22, 4000);
}
void loop() {
Serial.print("\t\t\t\t\t\t\t\t\t\t\t\t\t 0x"); Serial.println(cap1.touched(), HEX);
Serial.print("Filt: ");
for (uint8_t i=0; i<12; i++) {
Serial.print(cap1.filteredData(i)); Serial.print("\t");
}
Serial.println();
Serial.print("Base: ");
for (uint8_t i=0; i<12; i++) {
Serial.print(cap1.baselineData(i)); Serial.print("\t");
}
Serial.println();
delay(1000);
}