TFMini - Micro LiDAR Module - Issue

Hi,

I received my TFmini sensor, and it isn’t working unfortunately. Ive tried different libraries recommended by sparkfun and DFrobot, but it wont open serial connection. Im using an Arduino with a logic level converter for the RX and TX pins, and when I probe the serial comm pins with an oscilloscope I do not get any readings, the sensor isn’t sending any data back to the Arduino. I followed the wiring diagram that was proposed by Sparkfun and DF robot, which was the same, so Im fairly confident I got that right.

Any reccomendations?

Thanks,

Harry

Hi Harry,

What dev platform are you connected to, and what voltage is it running at?

The device won’t operate without being told to do so, and the Sparkfun example code has plenty of debug print statements. What debug text are you seeing for the function readDistace?

https://learn.sparkfun.com/tutorials/tfmini---micro-lidar-module-qwiic-hookup-guide

/*
  LidarTest.ino
  Written in collaboration by Nate Seidle and Benewake

  Example sketch for the Qwiic Enabled TFMini
  (https://www.sparkfun.com/products/14786)
*/

#include <Wire.h>

uint16_t distance = 0; //distance
uint16_t strength = 0; // signal strength
uint8_t rangeType = 0; //range scale
/*Value range:
 00 (short distance)
 03 (intermediate distance)
 07 (long distance) */

boolean valid_data = false; //ignore invalid ranging data

const byte sensor1 = 0x10; //TFMini I2C Address

void setup()
{
  Wire.begin();

  Serial.begin(115200);
  Serial.println("TFMini I2C Test");
}

void loop()
{
  if (readDistance(sensor1) == true)
  {
if (valid_data == true) {
  Serial.print("\tDist[");
  Serial.print(distance);
  Serial.print("]\tstrength[");
  Serial.print(strength);
  Serial.print("]\tmode[");
  Serial.print(rangeType);
  Serial.print("]");
  Serial.println();
}
else {
  //don't print invalid data
}
  }
  else {
Serial.println("Read fail");
  }
  delay(50); //Delay small amount between readings
}

//Write two bytes to a spot
boolean readDistance(uint8_t deviceAddress)
{
  Wire.beginTransmission(deviceAddress);
  Wire.write(0x01); //MSB
  Wire.write(0x02); //LSB
  Wire.write(7); //Data length: 7 bytes for distance data
  if (Wire.endTransmission(false) != 0) {
return (false); //Sensor did not ACK
  }
  Wire.requestFrom(deviceAddress, (uint8_t)7); //Ask for 7 bytes

  if (Wire.available())
  {
for (uint8_t x = 0 ; x < 7 ; x++)
{
  uint8_t incoming = Wire.read();

  if (x == 0)
  {
    //Trigger done
    if (incoming == 0x00)
    {
      //Serial.print("Data not valid: ");//for debugging
      valid_data = false;
      //return(false);
    }
    else if (incoming == 0x01)
    {
      Serial.print("Data valid:     ");
      valid_data = true;
    }
  }
  else if (x == 2)
    distance = incoming; //LSB of the distance value "Dist_L"
  else if (x == 3)
    distance |= incoming << 8; //MSB of the distance value "Dist_H"
  else if (x == 4)
    strength = incoming; //LSB of signal strength value
  else if (x == 5)
    strength |= incoming << 8; //MSB of signal strength value
  else if (x == 6)
    rangeType = incoming; //range scale
}
  }
  else
  {
Serial.println("No wire data avail");
return (false);
  }

  return (true);
}