Hi and thanks for you help.
I am running nearly the same code as you, with the exception that I have the setMode a bit further down and I haven't set extra dealy for that (might be somewhat the reason for the issues).
`
#include <Trill.h>
Trill trillSensor;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
int ret = trillSensor.setup(Trill::TRILL_FLEX);
if(ret != 0) {
Serial.println("failed to initialise trillSensor");
Serial.print("Error code: ");
Serial.println(ret);
}
// when the slider is connected we increase the
// prescaler to deal with the increased baseline
// capacitance it brings
trillSensor.setPrescaler(4);
delay(10);
// after any prescaler change, it's always good to update
// the baseline, too.
trillSensor.updateBaseline();
trillSensor.setMode(Trill::RAW);
}
void loop() {
// put your main code here, to run repeatedly:
delay(100);
trillSensor.requestRawData();
while(trillSensor.rawDataAvailable() > 0) {
int data = trillSensor.rawDataRead();
if(data < 1000)
Serial.print(0);
if(data < 100)
Serial.print(0);
if(data < 10)
Serial.print(0);
Serial.print(data);
Serial.print(" ");
}
Serial.println("");
}
`
I have been playing around with both a lot now
What i figured out so far
*your code with the delay and mode change earlier seems to be more robust (makes sense to have it earlier)
*the rev.A2 doesn't care what so ever. both of those codes work exactly the same
*the rev.C1 does care
One example that I have now that seems to be very reproducable.
I take your code, flash it on the UNO, have the C1 connected. I get good response to the changes, everything seems to be fine (signal around 500 at prescaler(4) with the flexPCB). I can take the Trill sensor off the hub an plug it back in, all fine.
I then flash my code. Everything is the same, all good. I unplug the Trill sensor, plug it back it and i get maxed out values (or around 2700 without flexPCB). I can reset the UNO, reflash the code, no changes. The complete power cycle seems to reset something. IF I reflash it to your code, back to normal.
And that only happens on the C1, A2 is code agnostic in that example.
I have a photo of my test set up attached, just for reference.

Also I might have at least one C1 that is broken, with 300-400 points higher signal on the first pin and very highly fluctuating baselines, making it not usable over the whole slider.
prescaler(4), no flexPCB:

I know I have a working solution now, but I would like to know why they behave so differently so I can avoid that in the future. But in general already thanks for you help, its very much appreciated!