How do i get my arduino mega to parse data to hls_lfcd_lds_driver? (Without USB2LDS) SOLVED

asked 2019-11-07 03:40:25 -0500

thallesgate gravatar image

updated 2020-08-19 14:12:31 -0500

Greetings! I have a HLS-LFCD2 Lidar connected through serial to an Arduino Mega (230400 baud rate), and i'm able to receive data from it and even tell it to start and stop (sending a "b" and an "e" respectively). But i dont know exactly how do i need to parse that data to make it talk to the hls_lfcd_lds_driver.

I tried doing a simple serial passthrough, and when i launch view_hlds_laser.launch , it spins but i cant see any data in rviz. The reference frame laser cannot be accessed by rviz.

On the arduino, i was able to run the drawLDS example, and i got all the points correctly. I just need to know how to send that data to ROS.

Is there any ROS lidar drivers that only need the angle and the distance data?

Here are some useful links The sensor information with datasheet: The example i ran on the Arduino Mega: Lidar Datasheet:

SOLUTION: If you don't have an adapter, look for the Specification Document PDF on the link above. Then, by looking at the pinout for the sensor, hook it up to your arduino. Just don't forget to step down the 5v of the TX pin of the arduino. You'll basically need a passthrough code, to get the serial data from the LIDAR and send it straight to the USB Serial at 230400 BAUD rate.

Something like this should work:

void setup() {

void loop() {
  if (Serial.available()) {      // If anything comes in Serial (USB),
    Serial1.write(;   // read it and send it out Serial1 (pins 0 & 1)

  if (Serial1.available()) {     // If anything comes in Serial1 (pins 0 & 1)
    Serial.write(;   // read it and send it out Serial (USB)

Notice that this sketch uses two Serial ports. Serial 0 (USB Serial) and Serial port 1 (Normally labelled TX1RX1 on the arduino pins). If you don't know how this works, look for Serial Ports on the Arduino wiki page.

edit retag flag offensive close merge delete


Hello, i baught a HLS-LFCD2 on Ebay. I m looking forward to use it for my project of robot law mover. Unfortunately i don't found any exemple on arduino for this lidar ( many exemple with RPLIDAR but library is not compatible). Can you help me to do a sketch on arduino Mega? Or may be you can send me your sketch to parse data? Best regards Vincent

lapoutre gravatar image lapoutre  ( 2020-03-29 13:34:11 -0500 )edit

So, basically, you have to look into the datasheet link up there on the question (look for the Detail Specification Document PDF). There you're going to have a Pin OUT for the LIDAR. You will have to basically power it with 5V (both the logic and the motor) and basically use the TX and RX pins (you can see which colour it is on the PDF) and connect them to the arduino's own TX and RX BUT WARNING remember to watch out for the maximum 3.3v tolerance of the rx pin from the lidar, as arduino digital pins outputs 5v instead of 3.3. For solving that, you can basically hook up a simple voltage divider(You can look for voltage divider calculator online for finding the correct resistor values). For using with ROS, you will need the hls_lfcd_lds_driver. You can find it on the ROS wiki ...(more)

thallesgate gravatar image thallesgate  ( 2020-03-31 05:28:29 -0500 )edit

@thallesgate: could you please post your last edit as an answer and then accept your own answer?

That would provide a much more visible indication that you've solved this.

Also: why did you close this question as a duplicate?

gvdhoorn gravatar image gvdhoorn  ( 2020-03-31 05:41:47 -0500 )edit

Hi, I'm trying to connect this lidar module to the Arduino but I cannot receive any data from it :( do you have any schematic how it should be connected to the arduino?

Bui Duy gravatar image Bui Duy  ( 2020-11-27 03:05:15 -0500 )edit

@thallesgate and other on this thread, can anyone post a wiring diagram or further examples? I've followed the wiring example from the Robtis link and have the connections running through a 5 to 3 volt level shifter. I am not getting any Serial output from the LIDAR when I run the Arduino code above on my Mega.

ninjix gravatar image ninjix  ( 2021-03-02 18:42:40 -0500 )edit

So, basically, you need to send a message to the LIDAR so that it begins operation. If you look at the datasheet, it says that "b" is the message needed. To stop the module, simply send an "e". (Just those two commands). You can test it by sending a b on the arduino serial terminal. Hope it helps!

thallesgate gravatar image thallesgate  ( 2021-03-03 01:01:01 -0500 )edit