Assistance with RPlidar - spins but doesn't provide data

Hello,

I'm new to using LiDAR - for this project, I'm working with a RPLiDAR. I'm using the attached code and the LiDAR spins, however, returns 0 for all values:

Edit: I'm using an Arduino Uno

#include <RPLidar.h>

// Create an instance of the RPLidar class
RPLidar lidar;

// Define the pin for controlling the LIDAR motor
#define RPLIDAR_MOTOR 7

void setup() {
  // Initialize Serial communication
  Serial.begin(115200);
  
  // Initialize the LIDAR
  lidar.begin(Serial);
  
  // Set the LIDAR motor pin as output
  pinMode(RPLIDAR_MOTOR, OUTPUT);
  
  // Start the LIDAR motor
  analogWrite(RPLIDAR_MOTOR, 255);
  delay(1000); // Wait for the motor to reach full speed
  
  // Start the LIDAR scanning
  lidar.startScan();
}

void loop() {
  if (lidar.waitPoint()) {
    // Get the current LIDAR data point
    float distance = lidar.getCurrentPoint().distance; // Distance value in mm
    float angle = lidar.getCurrentPoint().angle; // Angle value in degrees
    bool startBit = lidar.getCurrentPoint().startBit; // Whether this point is the start of a new scan
    byte quality = lidar.getCurrentPoint().quality; // Quality of the current measurement
    
    // Print the LIDAR data
    Serial.print("Distance: ");
    Serial.print(distance);
    Serial.print("mm");
    Serial.print(" | Angle: ");
    Serial.print(angle);
    Serial.print("°");
    Serial.print(" | Start Bit: ");
    Serial.print(startBit);
    Serial.print(" | Quality: ");
    Serial.println(quality);
  }
}

I get the following output:

Distance: 0.00mm | Angle: 0.00° | Start Bit: 0 | Quality: 0
Distance: 0.00mm | Angle: 0.00° | Start Bit: 0 | Quality: 0
Distance: 0.00mm | Angle: 0.00° | Start Bit: 0 | Quality: 0

Thank you!

Are you using a logic level converter?

Maybe this will help:

I'm not, I've directly plugged the Slamtec Rplidar A1 to the Arduino Uno, but I've taken a look at the link you provided and I may learn something from here because to my knowledge the specific Rplidar I'm using doesn't require a logic converter.

Thanks for the link!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.