Welcome to SDM18 Laser Ranging Module repository
2.Get distance information_ESP32
SDM18 and ESP32 Microcontroller Communication
SDM18 and ESP32 Microcontroller CommunicationSDM18 Introduction1. Experimental Preparation2. Experimental Wiring3. Experimental Steps4. Experimental Results5. Explanation of Some Important SDM18 Parameters and Default Values
SDM18 Introduction
The YDLIDAR SDM18 LiDAR (hereafter referred to as the SDM18) is a high-performance single-point LiDAR. This product utilizes the time-of-flight ranging principle and incorporates relevant optical, electrical, and algorithmic design to achieve high-precision laser distance measurement and output point cloud data at a high frame rate.
Product Features ➢ High ranging frequency, internal high sampling rate combined with filtering algorithm, ensures highly stable data ➢ Long detection range, up to 18 meters ➢ Lightweight, approximately 1.35g ➢ Laser power meets FDA Class I safety standards
1. Experimental Preparation
SDM18 Laser Ranging Module
ESP32 Series This tutorial uses the ESP32S3
2. Experimental Wiring
| ESP32 | SDM18 |
|---|---|
| TX1 (IO36) | RX |
| RX1 (IO35) | TX |
| GND | GND |
| 3.3V | 3.3V |
Note: You need to solder the pin headers to the serial port adapter board yourself. The default pin headers are not included. For this experiment, you will need to solder the pin headers to the adapter board (UART1 baud rate is 921600).
The wiring diagram is shown in the figure.

| ESP32S3 | USB-to-TTL module (needs to be purchased separately if not available) |
|---|---|
| RX0 | TX |
| TX0 | RX |
| GND | GND |
| 5V | 5V |
3. Experimental Steps
Download the provided program to the ESP32.
Open the serial port assistant and set the baud rate to 115200 (UART0: Communicates with the computer - outputs the received radar distance and signal strength)
4. Experimental Results
After connecting the cables and communicating normally, the serial port assistant will print out the measured distance information, as shown in the figure.

dis: Distance in mm
strength: Strength
5. Explanation of Some Important SDM18 Parameters and Default Values
The SDM18 interface is shown in the figure:

Default Serial Port Configuration The default baud rate of the SDM18 is 921600

Important Serial Port Protocol Commands (All Sent in Hexadecimal) The SDM18 defaults to idle mode upon power-up. To perform ranging, you must first issue the ranging start command.
Start ranging: A5 03 20 01 00 00 00 02 6E
Stop ranging: A5 03 20 02 00 00 00 46 6E
Protocol Analysis for Receiving Ranging

Checksum Calculation This checksum uses the CRC-16-modelbus calculation method, calculating all bytes except the check digit.
The following image shows the check digit calculation result for the "Start Ranging" command.

Other protocols will not be explained here. Interested parties can refer to the SDM18 Development Manual.