TFLuna-I2C icon indicating copy to clipboard operation
TFLuna-I2C copied to clipboard

Troubleshooting TFLuna sensor

Open authenticanthropoceneculture opened this issue 3 years ago • 1 comments

Hello—I'm using the example code "TFLI2C_simple.ino"; Arduino UNO; and a Benewake TF-Luna.

My issue is this: the only output is the setup print:

TFLI2C example code simplified 4 NOV 2021

No values coming out of the sensor. My question is this—I've got no red LED lit up on the TF-Luna; does this indicate that the sensor is broken? I'd obviously like to know whether I can skip more troubleshooting with the code and should instead just order another LIDAR sensor!

Much obliged—and thanks for providing all these helpful scripts and guides!


/* File Name: TFLI2C_simple.ino
 * Developer: Bud Ryerson
 * Date:      4 NOV 2021
 * Version:   0.1.2
 * Described: Simplified Arduino example sketch for the Benewake
 *            TF-Luna LiDAR sensor configured for the I2C interface
 */
 
#include <Arduino.h>     // every sketch needs this
#include <Wire.h>        // instantiate the Wire library
#include <TFLI2C.h>      // TFLuna-I2C Library v.0.2.0

TFLI2C tflI2C;

int16_t  tfDist;    // distance in centimeters
int16_t  tfAddr = TFL_DEF_ADR;  // use this default I2C address or
                                // set variable to your own value

void setup()
{
    Serial.begin( 115200);  // initialize serial port
    Wire.begin();           // initialize Wire library
    Serial.println( "TFLI2C example code simplified"); // say "Hello!"
    Serial.println( "4 NOV 2021");                     // and add date
}

void loop()
{
    if( tflI2C.getData( tfDist, tfAddr)) // If read okay...
    {
        Serial.print("Dist: ");
        Serial.println(tfDist);          // print the data...
    }
    else tflI2C.printStatus();           // else, print error.

    delay( 50);
}

Pins: 1 -> 5v, 2->SDA, 3-> SCL (switching these doesn't change anything), 4 -> GND, 5 -> GND

You wrote: "I've got no red LED lit up on the TF-Luna; does this indicate that the sensor is broken?" I think that the answer might be, "Yes." Check your power for proper voltage and polarity and check your connections. The device has to have a visible red glow. My apologies for taking so long to answer.

budryerson avatar Jun 01 '24 05:06 budryerson