Benewake TF03 question

I have a TF03 (100M) LIDAR from Benewake. I have software running on an Arduino UNO that displays the distance properly, as it should, but not the strength, even though the two commands are similar, and configured together. Here is program
`#include <SoftwareSerial.h>
#include <TFMini.h>
SoftwareSerial mySerial(2, 3); // RX, TX
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
TFMini tfmini;
uint16_t distance;
uint16_t strength;
//LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup(){
Serial.begin(115200);
while (!Serial);
//Wire.begin(); // start I2C
// lcd.begin(20, 4);
//mySerial.begin(TFMINI_BAUDRATE);
mySerial.begin(115200);
tfmini.begin(&mySerial);
//lcd.backlight();
}

void loop(){

  int distance=0;
int strength=0;
getTFminiData(&distance,&strength);
    while (!distance){
    getTFminiData(&distance,&strength);
   if(distance){
    Serial.print("Distance = ");
    Serial.print(distance);
    Serial.println("cm");
    Serial.print("Strength = ");
    Serial.println(strength);}}
    delay(100);   

}
void getTFminiData(int* distance, int* strength) {
static char i = 0;
char j = 0;
int checksum = 0;
static int rx[9];
if(mySerial.available())
{
// Serial.println( “tfmini serial available” );
rx[i] = mySerial.read();
if(rx[0] != 0x59) {
i = 0;
} else if(i == 1 && rx[1] != 0x59) {
i = 0;
} else if(i == 8) {
for(j = 0; j < 8; j++) {
checksum += rx[j];
}
if(rx[8] == (checksum % 256)) {
*distance = rx[2] + rx[3] * 256;
*strength = rx[4] + rx[5] * 256;
}
i = 0;
} else
{
i++;
}
}
}text`

Hello @foundb and welcome to the RobotShop forum,

Could you share the values you’re getting for the distance and the strength?

Also, what version of the TF03 do yo have?

1 Like