SEN0524 ToF Bad performance
Hello,
I've issues with poor performance when using the SEN0524 ToF sensor. I get a variation of around +-3cm with the sensor being fixed. The variation is pretty "slow", not really looking like random noise. See the plot attached for an example.
I'm using I2C to read the register, since there is limited information except the wiki, I might be doing something wrong:
#define TOF1_I2C_ADRESS 0x08
#define TOF_REG_DIST 0x24
tof1_distance = read_tof(TOF1_I2C_ADRESS, TOF_REG_DIST);
int read_tof(byte adress, byte reg) {
Wire.beginTransmission(adress);
Wire.write(reg);
int error = Wire.endTransmission(false);
if( error != 0) // can't find device
return -1;
int n = Wire.requestFrom(adress, byte(2));
if( n != 2) {
return -1; // can't read register
}
int first_byte = Wire.read();
int sec_byte = Wire.read();
return first_byte + sec_byte * 255;
}
Is there anything else I can do to increase the performance? What is the default range mode set?
Thanks