So my next step: determine when I’m not moving.
Here’s what hasn’t worked:
bool readyForSleep = accel.calibrateFilter(2000); // <<-- this doesn't work! need to figure out how to detect non-movement.
if (readyForSleep) { do stuff }
Giving it more time ala accel.calibrateFilter(2000, MORE_SECONDS);
is more of the same, but takes longer. I was hoping the bool would be false
if it wasn’t able to calibrate b/c of movement, but it appears to always be true
(?). Any chance this is a good fix but I’m implementing it wrong?
Also what doesn’t seem to work is using something like this from 4_Position to figure out when the detector is not moving:
void loop() {
LIS3DHConfig config;
config.setPositionInterrupt(16);
LIS3DHSample sample;
if (accel.getSample(sample)) {
Serial.printlnf("%d,%d,%d", sample.x, sample.y, sample.z);
}
I was hoping I could watch on the serial monitor that once it’s flat and not moving it would either show (0,0,0) or at the very least (stable, stable, stable) but it’s sitting here, undisturbed on my couch and it’s oscillating like crazy… 256,0,512 -> -256,0,0 -> 0,256,-768 -> 0,0,0 -> -256,-256,768 -> etc and it happens very quickly despite no noticable movement!
Is there a solution here that I’m perhaps implementing incorrectly? Or something completely different? I’m struggling here… 