Dear Seeed Engineers, dear Community,
I have been trying for some time now to read the shield LIS3DHTR as fast as I can.
According to the datasheet, this device can return values at 5kHz sampling frequency and when I measure the time to acquire a one triplet of acceleration - it takes around 1.7ms.
How to improve this performance?
Please find my modification of one example:
#include “LIS3DHTR.h”
#include <Wire.h>
LIS3DHTR LIS; //IIC
#define WIRE Wire
void setup() {
Serial.begin(115200);
while (!Serial) {};
LIS.begin(WIRE, 0x19); //IIC init
delay(100);
LIS.setFullScaleRange(LIS3DHTR_RANGE_2G);
LIS.setOutputDataRate(LIS3DHTR_DATARATE_5KHZ);
LIS.setHighSolution(true); //High resolution enable
LIS.setPowerMode(POWER_MODE_NORMAL);
WIRE.setClock(400000);
}
void loop() {
float x, y, z = {};
if (!LIS) {
Serial.println(“LIS3DHTR didn’t connect.”);
while (1);
return;
}
// Get acceleration on 3 axis
// Compute the time it took
unsigned long start = micros();
LIS.getAcceleration(&x, &y, &z);
unsigned long theend = micros();
unsigned long delta = theend - start;
Serial.println(delta);
delay(500);
}