A LiDAR sensor (Light Detection And Ranging) uses laser pulses and time-of-flight measurement to determine distance with millimetre-level precision. Once reserved for autonomous vehicles and aerospace applications costing tens of thousands of dollars, LiDAR modules like the TF-Luna are now available for under Rs. 1,500 and interface directly with Arduino or Raspberry Pi over UART or I2C. This guide covers how LiDAR works, the best available modules, how they compare with ultrasonic and IR sensors, and practical code examples for your next robotics or mapping project.
Table of Contents
- How LiDAR Works (Time of Flight)
- LiDAR vs Ultrasonic vs IR Sensors
- Popular Modules: TF-Luna, TFmini, RPLiDAR
- Specs Comparison Table
- Interfacing TF-Luna with Arduino
- Interfacing with Raspberry Pi
- 2D Scanning with Servo Motor
- Applications: Robotics, Drones, Agriculture
- Indian Pricing & Buying Guide
- FAQ
How LiDAR Works: Time of Flight Explained
LiDAR works by emitting a short pulse of laser light (typically 850 nm or 905 nm near-infrared, invisible to the human eye) and measuring how long it takes for the reflected pulse to return to a photodetector on the sensor. Since light travels at approximately 3 × 10^8 metres per second, the time-of-flight (ToF) measurement gives distance via a simple formula:
Distance = (Speed of Light × Time of Flight) / 2
Example: ToF = 10 nanoseconds
Distance = (3 × 10^8 m/s × 10 × 10^-9 s) / 2
Distance = 3 m / 2 = 1.5 metres
The division by 2 accounts for the round trip (out and back). Modern ToF chips like the Benewake VCSEL driver measure time differences at picosecond resolution — this is why compact LiDAR modules can achieve ±2–6 cm accuracy at 8 metres.
There are two primary ToF approaches used in compact LiDAR modules:
- Direct ToF (dToF): Measures the actual time delay of a single pulse. Used in TFmini and TF-Luna. Gives longer range and works well in direct sunlight.
- Indirect ToF (iToF / Phase-shift): Modulates a continuous wave laser at known frequencies and measures the phase shift of the returned signal. Used in many 3D ToF cameras (Intel RealSense D435i). Shorter range but can build a depth image.
The compact single-point LiDAR modules (TF-Luna, TFmini) use direct ToF and measure one distance point per measurement cycle. Rotating LiDAR modules (RPLiDAR, YDLIDAR) add a spinning mirror to sweep the laser across a 360-degree plane, building a 2D distance map.
LiDAR vs Ultrasonic vs IR Sensors
Choosing between LiDAR, ultrasonic (HC-SR04), and IR distance sensors depends on your accuracy requirements, environment, and budget:
| Property | LiDAR (TF-Luna) | Ultrasonic (HC-SR04) | IR (Sharp GP2Y) |
|---|---|---|---|
| Range | 0.2–8 m | 2 cm – 4 m | 10–80 cm |
| Accuracy | ±2 cm | ±3 mm (short range) | ±5–10% (non-linear) |
| Update Rate | Up to 250 Hz | ~20–40 Hz (blocking) | ~40 Hz (analog) |
| Beam Angle | 2 degrees (very narrow) | 15–30 degrees (wide cone) | 5–10 degrees |
| Sunlight Performance | Good (indoor + outdoor) | Excellent (not affected) | Poor (sunlight interference) |
| Object Detection | Most surfaces | Solid surfaces only | Most surfaces (colour dependent) |
| Interface | UART / I2C | Digital (trigger/echo) | Analog voltage |
| Price (India) | Rs. 1,200–1,800 | Rs. 40–80 | Rs. 200–400 |
| Best For | Robotics, drones, mapping | Simple obstacle avoidance | Line following, short-range detection |
LiDAR’s narrow 2-degree beam is an advantage for precision point measurement (no ambiguity about exactly which object you are measuring) but means it only sees one point at a time. Ultrasonic has a wide cone — useful for detecting anything in a general direction but unable to distinguish between a wall and a nearby object at a slight angle. IR sensors are affected by ambient sunlight and object reflectivity — a black surface returns much less IR than a white one, making distance readings unreliable for dark objects.
Popular LiDAR Modules
Benewake TF-Luna (0.2–8 m)
The TF-Luna is the current go-to module for makers and robotics projects in India. It measures 35mm x 21.25mm x 13.5mm and weighs just 5 grams — small enough to mount on a drone or small robot. The dual interface (UART at 115200 baud OR I2C at 0x10) makes it compatible with virtually any microcontroller. Output is a 9-byte data frame at rates from 1 Hz to 250 Hz. Minimum distance is 20 cm (the blind zone); accuracy is ±2 cm at 3 m and degrades to ±4 cm at 8 m. Operating voltage is 3.3V or 5V (the logic is 3.3V; there is a built-in regulator from 5V). Excellent choice for a first LiDAR project.
Benewake TFmini / TFmini Plus (0.1–12 m)
The TFmini is the predecessor to the TF-Luna, slightly larger but with longer range (12 m for TFmini Plus). Also uses UART/I2C. The TFmini-S is the industrial variant with IP65 protection — suitable for outdoor installations like drone landing zone detection or agriculture canopy height measurement. Price is Rs. 1,800–2,500 depending on variant.
Benewake TF-LC02 (0.02–2 m)
A short-range module optimised for very close distances, with a minimum range of just 2 cm. Uses a VCSEL laser diode and is designed for IoT and ITS (Intelligent Transportation Systems) applications — parking sensors, occupancy detection, people counting. UART interface, 3–3.6V supply, 100 Hz measurement rate.
RPLiDAR A1M8 (0.15–12 m, 360 degrees)
The RPLiDAR from Slamtec is a rotating 2D LiDAR that spins at 5.5 Hz (330 RPM) and takes 8,000 samples per second, producing a full 360-degree distance map. It connects via USB (CDC serial) and has official ROS (Robot Operating System) packages. Price is Rs. 8,000–12,000 in India. Ideal for robot SLAM (Simultaneous Localisation and Mapping), indoor mapping, and autonomous navigation.
Benewake AD2-S-X3 (Automotive Grade)
A high-performance automotive-grade LiDAR for autonomous driving research and vehicle ADAS applications. Far beyond maker-level use cases but available from Zbotic.in for serious research projects and EV development teams.
Interfacing TF-Luna with Arduino (UART Mode)
The TF-Luna communicates via UART at 115200 baud by default. Here is a complete Arduino Uno sketch using SoftwareSerial:
#include <SoftwareSerial.h>
// TF-Luna UART wiring:
// Luna TX (white) --> Arduino pin 10 (RX of SoftSerial)
// Luna RX (green) --> Arduino pin 11 (TX of SoftSerial)
// Luna GND --> Arduino GND
// Luna 5V --> Arduino 5V
SoftwareSerial luna(10, 11); // RX, TX
void setup() {
Serial.begin(115200); // USB serial monitor
luna.begin(115200); // TF-Luna default baud rate
delay(100);
Serial.println("TF-Luna LiDAR distance reader started");
}
float readDistance() {
while (luna.available() < 9) {} // Wait for a full 9-byte frame
if (luna.read() == 0x59) { // First header byte
if (luna.read() == 0x59) { // Second header byte
byte low = luna.read(); // Distance low byte
byte high = luna.read(); // Distance high byte
luna.read(); // Strength low
luna.read(); // Strength high
luna.read(); // Temp low
luna.read(); // Temp high
luna.read(); // Checksum (skip validation for simplicity)
int distance_cm = (high << 8) | low;
return distance_cm;
}
}
// Flush and try again on bad frame
while (luna.available()) luna.read();
return -1;
}
void loop() {
float dist = readDistance();
if (dist > 0) {
Serial.print("Distance: ");
Serial.print(dist);
Serial.println(" cm");
}
delay(50); // 20 Hz read rate
}
Wiring notes: The TF-Luna has a 6-pin JST-GH connector. From left to right: +5V, GND, RX, TX, SDA, SCL. In UART mode, only +5V, GND, RX (to Arduino TX), and TX (to Arduino RX) are needed. On Arduino Mega or Arduino Due, use hardware Serial1/Serial2 instead of SoftwareSerial for more reliable high-speed communication.
Interfacing TF-Luna with Raspberry Pi
On Raspberry Pi, use the hardware UART (GPIO 14/15, /dev/ttyS0 or /dev/ttyAMA0) for reliable 115200 baud communication. First, disable the Bluetooth UART overlay in /boot/config.txt (dtoverlay=disable-bt) and disable the serial console in raspi-config. Then use Python:
import serial
import time
# Wiring: Luna TX --> RPi GPIO 15 (RXD, pin 10)
# Luna RX --> RPi GPIO 14 (TXD, pin 8)
# Luna 5V --> RPi pin 2 (5V)
# Luna GND--> RPi pin 6 (GND)
ser = serial.Serial('/dev/ttyS0', 115200, timeout=1)
def read_tfluna():
while True:
if ser.read(1) == b'x59':
if ser.read(1) == b'x59':
data = ser.read(7)
dist_cm = data[0] + (data[1] << 8)
strength = data[2] + (data[3] << 8)
if strength > 100: # Filter weak returns
return dist_cm
return -1
while True:
dist = read_tfluna()
print(f"Distance: {dist} cm")
time.sleep(0.1)
For I2C mode: set the TF-Luna to I2C mode by sending a configuration command via UART first (see the TF-Luna Product Manual for the command byte sequence). I2C address defaults to 0x10. On Raspberry Pi, use smbus2 library to read 9 bytes from register 0x01.
2D Scanning with a Servo Motor
A single TF-Luna mounted on a servo motor creates a basic 2D scanner. Mount the TF-Luna on an SG90 servo, sweep from 0 to 180 degrees in 1-degree steps, and record the distance at each angle. This creates a polar distance array you can visualise as a 2D map.
#include <Servo.h>
#include <SoftwareSerial.h>
Servo scanServo;
SoftwareSerial luna(10, 11);
float distances[181]; // 0 to 180 degrees
void setup() {
Serial.begin(115200);
luna.begin(115200);
scanServo.attach(9);
delay(500);
}
float readLuna() {
while (luna.available() < 9) {}
if (luna.read() == 0x59 && luna.read() == 0x59) {
byte lo = luna.read(), hi = luna.read();
for (int i = 0; i < 5; i++) luna.read();
return (hi << 8) | lo;
}
while (luna.available()) luna.read();
return -1;
}
void loop() {
// Sweep 0 to 180
for (int angle = 0; angle <= 180; angle++) {
scanServo.write(angle);
delay(20); // Let servo settle
distances[angle] = readLuna();
Serial.print(angle);
Serial.print(",");
Serial.println(distances[angle]);
}
delay(500);
}
Send the output over serial to a Python script using matplotlib to draw a polar plot in real time. This makes a simple room scanner, obstacle map for a robot, or demonstrator for a science project. The scan speed is limited by servo movement time (~20 ms per degree) and LiDAR measurement rate (up to 250 Hz on TF-Luna). A full 180-degree sweep takes about 4 seconds at this rate.
Applications
Mobile Robotics and Obstacle Avoidance
LiDAR is the preferred sensor for indoor robots because of its accuracy, narrow beam, and ability to detect transparent surfaces that confuse IR sensors. Mount a TF-Luna at the front of a rover, and use distance readings to stop and turn before collisions. For full 360-degree mapping, the RPLiDAR A1 with ROS and the gmapping or hector_slam package creates a metric map of the environment — the foundation for autonomous navigation.
Drone Altitude Hold and Landing Zone Detection
The TFmini-S (IP65) is used widely in DJI-compatible drone accessory boards for altitude hold close to ground (0.1–12 m range). The narrow beam directly below the drone gives an accurate terrain-following height measurement unaffected by barometric pressure fluctuations. The TF-LC02 (2 cm minimum range) is used for precision landing detection.
Agriculture: Canopy Height and Sprayer Control
Agricultural drones use LiDAR for terrain following in uneven fields and for canopy height measurement (to adjust spray nozzle height and chemical dosage). The TFmini-S’s outdoor performance and IP65 rating make it suitable for field conditions. Indian agricultural drone startups are adopting Benewake LiDAR modules for precision agriculture applications.
Smart Parking and Level Measurement
The TF-LC02’s 2 cm minimum range and high update rate make it ideal for parking space occupancy detection (is a vehicle present at under 2 m?) and industrial level measurement (tank fill level, bin fill height). UART output simplifies integration with ESP32-based IoT nodes reporting to cloud dashboards.
Indian Pricing & Buying Guide
LiDAR modules were difficult to source in India until recently. Zbotic.in now stocks the key Benewake modules:
- Benewake TF-Luna (8 m): Rs. 1,200–1,500 — best value for most projects
- Benewake TF-LC02 (2 m, short-range): Rs. 800–1,200 — for IoT and parking applications
- Benewake TFmini-S (12 m, IP65): Rs. 2,200–2,800 — for outdoor and drone use
- RPLiDAR A1M8 (360°, 12 m): Rs. 8,000–12,000 — for full SLAM mapping robots
When choosing a module, consider: (1) Range — the TF-Luna at 8 m covers most indoor robotics scenarios. (2) Environment — if outdoors, IP65 protection matters. (3) Interface — UART is simpler for Arduino; I2C is better when sharing a bus with other sensors. (4) Minimum range — the TF-Luna has a 20 cm blind zone; for very close detection, use the TF-LC02.
Frequently Asked Questions
Q: Can a LiDAR sensor detect transparent objects like glass?
Standard near-IR LiDAR (850–905 nm) partially penetrates glass. The TF-Luna will often not detect a clear glass window — the beam passes through with too little reflection to trigger a valid return. This can be a problem for window detection in robot navigation. Use a backup ultrasonic sensor at windows, or choose a LiDAR with a longer wavelength (1550 nm) which reflects off glass better — but these are expensive industrial units.
Q: Does LiDAR work outdoors in Indian sunlight?
Yes, but with limitations. Direct sunlight contains significant 850–905 nm infrared energy that can overwhelm the sensor’s photodetector. The TF-Luna specifies outdoor use up to 70,000 lux ambient illumination. Avoid pointing the sensor directly at the sun or at sunlit white surfaces. Mounting the sensor in shade, or using a short baffle tube around the lens, significantly improves outdoor performance.
Q: What is the difference between LiDAR and ToF camera (depth camera)?
A single-point LiDAR module measures distance to one point in front of it. A ToF depth camera (like the Intel RealSense D435i or Azure Kinect) uses an array of VCSEL emitters and a 2D photodetector array to measure depth at every pixel simultaneously, generating a depth image. Depth cameras are for 3D scanning, gesture recognition, and augmented reality. Single-point LiDAR is for range finding, altitude hold, and 2D scanning with a servo.
Q: Can I use multiple TF-Luna sensors on one Arduino?
Yes. In UART mode, use multiple SoftwareSerial instances on different pin pairs (though only one can listen at a time). In I2C mode, all sensors default to address 0x10 — change each sensor’s address via a UART configuration command before connecting them all to the I2C bus. Addresses 0x10 through 0x77 are available, giving you up to 104 sensors on one I2C bus.
Q: Is LiDAR better than ultrasonic for a simple robot obstacle avoidance project?
For beginner projects with an HC-SR04 already on hand, ultrasonic is simpler and much cheaper. LiDAR becomes worthwhile when you need: longer range (beyond 4 m), faster update rate (HC-SR04 is slow due to blocking pulseIn()), narrower beam angle (LiDAR at 2 degrees vs ultrasonic at 15–30 degrees), or outdoor use where ultrasonic wind sensitivity is an issue. If budget allows, the TF-Luna’s accuracy and speed make it the superior choice for serious robotics.
Get Your LiDAR Sensor from Zbotic.in
Zbotic.in stocks Benewake TF-Luna, TF-LC02, and automotive-grade LiDAR modules with fast delivery across India. Perfect for robotics, drones, IoT, and research projects.
Add comment