How to Use the RPLIDAR 360° Laser Scanner With Arduino




Introduction: How to Use the RPLIDAR 360° Laser Scanner With Arduino

About: Hello, I'm Bruce. I'm a student in Belgium. I have a wide variety of interests: electronics, computers, technology, ... In my spare time I spend a lot of time on: projects, exploring the internet, cycling. ht…

I'm a big fan of building sumo robots and I'm always on the look for new interesting sensors and materials to use to build a better, faster, smarter robot. I found out about the RPLIDAR A1 which you can get for $99 at . I said I was interested in trying out this sensor and they gave me the chance to try one. After I got the LIDAR I found out I was not allowed to use this type of sensor in the competition I'm planning to attend because it's too expensive.

In this tutorial I'll give you a basic understanding of how this sensor works and how you can use it with an arduino.

Step 1: LIDAR What?

Wikipedia had two different meanings for LIDAR:
- LIght Detection And Ranging
- Laser Imaging Detection And Ranging

In general it can be seen as a distance sensor on a rotating base, which samples range data while continuously rotating. For each successful sample the measured distance is sent with the according angle.
In this case the data is sent over UART.

Step 2: Using an Arduino to Interface With the LIDAR

The LIDAR needs to be connected to the hardware serial port (UART) of the Arduino, for an basic arduino this means you can't send any UART data to the serial console. Because they have only one Serial port. For basic Arduino's with only 1 hardware serial port, you can add an extra software serial port. The library that'll be used in this instructable doesn't support a software serial port (at the moment of writing).

So if you want to be able to send send serial data to the serial console for debugging purposes you'll need an arduino with more than one Serial port. Like there are: Arduino Mega, Arduino M0 / Zero (SAMD21).
If you don't need to send data to the computer to debug you can pick any arduino.

For this instructable I'll be using a more modern and more powerful arduino based on the SAMD21 microcontroller, The Arduino M0 / Zero.

Required parts:

  1. First you'll need to install the RPLIDAR library from robopeak:, this library offers 2 interesting examples on how to use the LIDAR. You can find more information on how to install a library in the arduino IDE in this article:

  2. Now open the "simple_connect" example code that is included in the library.
  3. Make the necessary hardware connections from the LIDAR to the arduino:
    - Connect the RPLIDAR's serial port (RX/TX/GND) to your Arduino board (Pin 0 and Pin1)

    - Connect the RPLIDAR's motor ctrl pin to the Arduino board pin 3
    - Use an external 5V power supply to power the motor control pin and the LIDAR.

  4. In the void setup you'll have to change following code: "lidar.begin(Serial);" according to the used serial port. When using an Arduino M0 you should change "Serial" to "Serial1". This can be different for other Arduino's.
  5. The first picture is what the example sketch should look like, lines 60-63 contain the variable names which you can use to get the data from the LIDAR.
  6. If you want to know what this data looks like you can print this data to the serial monitor, with the code in the second picture.

In the following step we'll make a very basic working project with the LIDAR and a LED ring.

Step 3: Making the LIDAR LED Ring Project

For this project we will mount an addressable led ring onto the LIDAR. This way we can visualize the LIDAR data.
In this specific program the LED will be turned on in the direction of the closest detected signal.

The code for this project is based on one of the examples from robopeak:

The changed code for this project is included in the zip file in this step.

Needed parts:

- LED ring: with 24 LEDS big enough to fit over the LIDAR, inner diameter 70mm
- Arduino Zero
- Separate 5V power supply
- 3D printed part:

  1. Get all the needed parts
  2. Solder the wires to the LED ring
  3. Glue the LED ring to the 3d printed part
  4. Mount the 3D printed part onto the LIDAR, there are holes in the 3Dprinted part for M2.5 screws but I didn't had them laying around to I just used hot glue
  5. Connect the wires from the LIDAR to the arduino:
    GND -> GND
    5V -> 5V of separate power supply
    Di -> pin D5 of arduino
  6. Upload the sketch and power up the external power supply

Final result can be viewed here on youtube:

Optics Contest

Participated in the
Optics Contest

Be the First to Share


    • Hand Tools Only Challenge

      Hand Tools Only Challenge
    • Modify It Speed Challenge

      Modify It Speed Challenge
    • Remix Contest

      Remix Contest

    9 Discussions


    5 weeks ago

    Hi. Nice idea. Thank you to share it.
    May be some small errors get into your text, please tell me if I'm wrong (see enclosing multiple stars *** below):

    Error1: May be replace LIDAR->LED RING
    Phrase: Connect the wires from the ***LIDAR*** to the arduino:

    Error2: May be replace "motor control pin and the LIDAR" with "LIDAR's V5.0 and VMOTO pin"
    Phrase: Use an external 5V power supply to power the ***motor control pin and the LIDAR***.

    So, can i resume the pin mapping as the following ?:
    RPLIDAR TX:: ARDUINO RX (hardware serial0 or serial1 or serial2)
    RPLIDAR RX: ARDUINO TX (hardware serial0 or serial1 or serial2)

    Best regards


    Question 11 months ago on Step 3

    Where would you connect the Analog pin?


    Question 11 months ago on Step 2

    Do you need to use a lvl shifter in order to make this work? Also would it be possible to get a better angle of the set up?


    Question 1 year ago

    Hallo, könnte man den code so ändern dass nicht die LED`s leuchten sondern der Wert des Winkels und der Distance auf dem seriellen Monitor dargestellt wird ?


    Answer 1 year ago

    Yep, just use Serial.print(distance); and Serial.print(angle);, check out the author's screenshots in step 2.


    Reply 1 year ago

    Hallo, vielen Dank. Das werde ich sofort umsetzen...Hätte ich auch allein drauf kommen können....Danke. Mal eine Frage nebenbei - wie alt sind Sie eigentlich ? Sie sehen auf dem Bild noch sehr jung aus - und schon so erfahren im Umgang mit dem Arduino.....super. Ich bin 70 und soll nun ein Projekt umsetzen von dem ich so gut wie nichts weiß. Der RPLidar ist absolutes Neuland - na ja, wenn man so schlaue Menschen neben sich hat geht das schon irgendwie......also nochmal vielen Dank.


    Question 1 year ago on Step 1

    Hallo, genau das, was ich gesucht habe. Leider zeigt er mir beim kompilieren an (ich beziehe mich auf den rechten Sketch) ..SerialUSB is not declared..Bin mal einfach rein geworfen worden in diese Problematik und versuche nun mich rein zu finden. Wir möchten die Daten des RPLidar auslesen und auf dem seriellen Monitor darstellen...erst mal. Kann mir bitte jemand helfen ? Ich habe den RPLidar A1, Arduino Mega.

    Vielen Dank


    1 year ago

    This is great...Thanks


    1 year ago

    Interesting 'ible. Thanks.