β οΈ Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through our links, we may earn a small commission at no extra cost to you. Every product below was checked against its live Amazon listing before publishing. Prices change often, so we don’t list them here. Tap any Buy Here button to see the current price on Amazon.
ESP32 Sensor Buying Guide
π Best Distance Sensors for ESP32
From 5 mm to 40 m: 9 LiDAR, time-of-flight and ultrasonic sensors that work with the ESP32, compared on range, interface, voltage and the jobs they actually suit.
β
9 Sensors Compared
β
Verified Amazon ASINs
β
3.3 V Wiring Notes
β
Honest Pros & Cons
Distance sensing shows up in a huge number of ESP32 projects: robot cars that avoid walls, water tank and bin level monitors, parking sensors, people counters at a doorway, touchless switches and drone altitude hold. The ESP32 handles all of them easily, but the sensor you pick decides whether readings are rock steady or jump around, whether it survives outdoors, and whether it even talks to a 3.3 V chip without extra parts.
This guide compares 9 sensors across the three main technologies: single-point LiDAR (Benewake TF-Luna, TFmini-S, TF02-Pro), ST time-of-flight chips (VL53L1X, VL53L0X, VL6180X and an 8×8 multizone sensor) and ultrasonic modules (HC-SR04 and the waterproof JSN-SR04T). For each one we note range, interface and supply voltage, since those are the details that matter most when wiring to an ESP32.
π‘ Before you buy: Check logic levels and target surface. The ESP32’s GPIO pins are 3.3 V only, and the HC-SR04’s echo pin outputs 5 V, so it needs a simple voltage divider. Optical sensors (LiDAR and ToF) read poorly on black, shiny or transparent targets and in strong sunlight, while ultrasonic sensors struggle with soft or angled surfaces. Match the technology to what you’re measuring, not just the range on the box.
β‘ Quick Comparison: All 9 Sensors
| Sensor | Type | Range | Interface | Best For | Buy |
|---|
| π₯ Benewake TF-Luna | Single-point LiDAR | 0.2 to 8 m | UART / I2C, 3.3 V logic | Best Overall | Buy Here β |
| π CQRobot VL53L1X | ToF chip | Up to 4 m | I2C | Best I2C ToF | Buy Here β |
| π MakerFocus TFmini-S | Single-point LiDAR | 0.1 to 12 m | UART / I2C, 5 V supply | Best Long-Range Micro LiDAR | Buy Here β |
| πΉ HiLetgo VL53L0X | ToF chip | Up to 2 m | I2C | Best Budget ToF | Buy Here β |
| π ELEGOO HC-SR04 (5 pack) | Ultrasonic | 2 cm to 5 m (listing) | Trig / Echo, 5 V | Best Ultrasonic Starter | Buy Here β |
| β Adafruit VL6180X | ToF chip | 5 to 100 mm | I2C (STEMMA QT) | Best Close-Range | Buy Here β |
| πͺ DFRobot 8×8 Matrix ToF | Multizone ToF | 20 mm to 4 m, 64 zones | I2C / UART | Best Multizone | Buy Here β |
| π‘οΈ youyeetoo Benewake TF02-Pro | Single-point LiDAR, IP65 | Up to 40 m | UART / I2C | Best Outdoor Long Range | Buy Here β |
| π§ hiBCTR JSN-SR04T (2 pack) | Waterproof ultrasonic | 25 cm to 4 m | Trig / Echo, 5 V | Best Waterproof | Buy Here β |
Specs come from the manufacturers and the live Amazon listings. Star scores below are our ratings.
π What Matters in a Distance Sensor
π
Real Range
Headline range assumes a large, bright target indoors. Plan for less on dark surfaces and in sunlight, and buy some headroom.
π
Interface and Voltage
I2C sensors share two pins; UART LiDAR uses a spare hardware serial port. Check supply voltage and that outputs are 3.3 V safe.
π―
Beam Width
LiDAR beams are about 2 to 3 degrees wide and hit one spot. Ultrasonic and ToF cones are wider and see more of the scene, including walls you don’t want.
βοΈ
Environment
Outdoors, in tanks or near water, pick a sealed sensor: the IP65 TF02-Pro for light, the JSN-SR04T probe for sound.
β±οΈ
Update Rate
Fast robots and drones want 100 Hz or more, which Benewake LiDAR delivers. Tank levels are fine with one reading a minute.
π Detailed Reviews: The Top Two
π₯ BEST OVERALL FOR ESP32
Benewake TF-Luna LiDAR Module
β 4.7/5 Β· Our Rating Β· The Sweet Spot
Buy on Amazon β

The TF-Luna is the easiest way to give an ESP32 real LiDAR. This tiny Benewake module measures 0.2 to 8 m with a narrow beam of about 2 degrees, so it reads the one spot it’s pointed at instead of the whole room. It runs from 3.7 to 5.2 V (the ESP32 board’s 5 V pin works) while its serial lines use 3.3 V logic, so it connects straight to a hardware UART or the I2C bus with no level shifter. The frame rate is adjustable up to 250 Hz, which is plenty for robots, drones and fast level sensing. Accuracy is quoted at about Β±6 cm up to 3 m and 2% beyond. It weighs only a few grams.
β
Pros- 3.3 V logic, ESP32 friendly
- Narrow, stable beam
- UART or I2C
- Tiny and light
β Cons- 20 cm blind zone
- Not sealed for outdoor use
- Fine-pitch connector
π― Verdict: The best all-round distance sensor for ESP32 projects that need real range and steady readings.
π Check Price on Amazon β
π BEST I2C TIME-OF-FLIGHT SENSOR
CQRobot VL53L1X ToF Long Distance Sensor
β 4.6/5 Β· Our Rating Β· Small, Cheap, Accurate
Buy on Amazon β

ST’s VL53L1X is the go-to I2C distance chip, and CQRobot’s breakout makes it easy to wire. It measures up to 4 m at up to 50 Hz, using an invisible 940 nm laser and a timing sensor, so readings don’t depend on target colour as much as cheap IR sensors. You can shrink its region of interest to narrow the field of view, which helps in corridors or when you only care about the middle of the scene. It sits on the same two I2C pins as your displays and other sensors, and the board works with 3.3 V and 5 V controllers. Range drops in bright sunlight and on dark targets, as with every optical sensor.
β
Pros- 4 m on two I2C pins
- Adjustable region of interest
- Mature Arduino libraries
- Very affordable
β Cons- Wider cone than LiDAR
- Weak in direct sunlight
- Multiple units need XSHUT wiring
π― Verdict: The best value indoor distance sensor for ESP32 robots, people counters and level sensing up to a few metres.
π Check Price on Amazon β
π§ Detailed Reviews: LiDAR, ToF and Ultrasonic
π BEST LONG-RANGE MICRO LIDAR Β· β 4.6/53. MakerFocus TFmini-S Micro LiDAR Module
0.1 to 12 m Β· up to 1000 Hz Β· UART or I2C Β· 5 V supply, 3.3 V logic
Buy Here β

The TFmini-S is the TF-Luna’s bigger brother. It stretches the range to 12 m, shortens the blind zone to 10 cm and can report up to 1000 times a second, which is why it’s popular for drone altitude hold, long hallways and car park sensing. It needs a 5 V supply, but its UART and I2C lines run at 3.3 V, so it still wires straight to the ESP32. The same Benewake serial protocol as the TF-Luna means the same code works with both.
β
Pros: 12 m range; very fast; short blind zone.
β Cons: Needs 5 V; not sealed.
π― Verdict: Pick this over the TF-Luna when you need more than 8 m or very fast updates.
πΉ BEST BUDGET TOF Β· β 4.4/54. HiLetgo VL53L0X Time-of-Flight Sensor Breakout
Up to 2 m Β· 940 nm laser Β· I2C Β· tiny breakout
Buy Here β

The VL53L0X is the older, cheaper sibling of the VL53L1X, with a range of about 2 m under good conditions and a more realistic 1 m or so on typical targets. For short jobs, like detecting a hand, a parcel in a mailbox, a car in a garage bay or an obstacle in front of a small robot, it’s plenty, and it’s one of the cheapest ways to add laser ranging to an ESP32 over I2C. ESPHome also has a ready-made VL53L0X component, so it’s easy to bring into Home Assistant.
β
Pros: Very cheap; small; ESPHome support.
β Cons: Short range; generic board quality varies.
π― Verdict: The budget pick for short-range presence and obstacle detection.
π BEST ULTRASONIC STARTER PACK Β· β 4.4/55. ELEGOO HC-SR04 Ultrasonic Sensor (5 Pack)
2 cm to 5 m (listing) Β· 40 kHz Β· under 15Β° beam Β· 5 V trig/echo
Buy Here β

The HC-SR04 is the classic first distance sensor, and ELEGOO’s five-pack is a dependable way to buy it. It times a 40 kHz sound pulse, so it doesn’t care about colour, transparency or sunlight, and it reads glass and clear plastic that confuse optical sensors. ELEGOO quotes 2 cm to 5 m and a beam under 15 degrees; expect a few metres in practice. It’s a 5 V part: power it from the 5 V pin and put a resistor divider (for example 1 kΞ© and 2 kΞ©) on the echo line before it reaches the ESP32. Soft materials like curtains and angled surfaces can absorb or deflect the echo.
β
Pros: Colour blind; reads glass; five sensors per pack.
β Cons: 5 V echo needs a divider; wide, noisy beam.
π― Verdict: The cheapest way to learn distance sensing and build a robot car’s eyes.
β BEST CLOSE-RANGE Β· β 4.5/56. Adafruit VL6180X Time-of-Flight Sensor (STEMMA QT)
5 to 100 mm Β· ambient light sensor Β· I2C Β· STEMMA QT / Qwiic Β· 3 to 5 V
Buy Here β

Most distance sensors have a blind zone right in front of them. The VL6180X is the opposite: it’s built for 5 to 100 mm, making it ideal for touchless buttons, detecting a cup under a dispenser, counting items dropping through a chute or sensing a lid. It also includes an ambient light sensor. Adafruit’s board adds a regulator, level shifting and STEMMA QT connectors, so it plugs into ESP32 boards with a Qwiic or STEMMA port without soldering.
β
Pros: Accurate up close; solderless STEMMA QT; good docs.
β Cons: Only about 10 cm range.
π― Verdict: The right sensor when the target is centimetres away, not metres.
πͺ BEST MULTIZONE / DEPTH MAP Β· β 4.5/57. DFRobot Gravity 8×8 Matrix ToF 3D Distance Sensor
VL53L7CX + RP2040 Β· 64 zones Β· 60Β° FOV Β· 20 mm to 4 m Β· I2C / UART Β· 3.3 to 5 V
Buy Here β

Instead of one distance, this sensor returns a grid of 64 distances across a wide 60 degree view, like a very low-resolution depth camera. That lets an ESP32 tell where an obstacle is, not just that one exists, and it opens up gesture detection, people counting and simple bin-fill mapping. An onboard RP2040 handles the heavy VL53L7CX driver, so the ESP32 just reads results over I2C or UART. DFRobot’s wiki includes ESP32 examples, quotes 15 to 60 Hz ranging and allows up to four units on one bus.
β
Pros: 64-zone depth grid; driver offloaded; ESP32 examples.
β Cons: Pricier than single-point ToF; more data to process.
π― Verdict: The pick for gestures, smarter obstacle avoidance and anything that needs a picture, not a number.
π‘οΈ BEST OUTDOOR LONG RANGE Β· β 4.6/58. youyeetoo Benewake TF02-Pro LiDAR (IP65)
Up to 40 m Β· IP65 housing Β· UART / I2C Β· 5 V Β· about 3Β° beam
Buy Here β

When the sensor has to live outside or reach far, the TF02-Pro is the step up. Its IP65 housing shrugs off rain and dust, it measures up to 40 m on reflective targets (less on dark ones), and it copes with much stronger ambient light than the micro LiDARs. That makes it suitable for gate and driveway sensing, silo and pond levels, and drones. It speaks the same Benewake UART and I2C protocols as the TF-Luna and TFmini-S, so code carries over. It’s larger, heavier and needs a solid 5 V supply.
β
Pros: 40 m range; IP65; handles sunlight better.
β Cons: Bulkier; the most expensive pick.
π― Verdict: The outdoor and long-distance choice when micro LiDAR isn’t enough.
β Also Worth Considering
π§ BEST WATERPROOF Β· β 4.3/5
9. hiBCTR JSN-SR04T Waterproof Ultrasonic Sensor (2 Pack)
For water tanks, sumps, rain barrels and car parking sensors, the JSN-SR04T puts a sealed ultrasonic transducer on a cable, with the electronics on a separate board you can keep dry. The listing quotes 25 cm to 4 m. It uses the same trigger and echo scheme as the HC-SR04 (so the same 5 V echo divider applies), and ESPHome has a dedicated JSN-SR04T component. Mount it pointing straight down at the water surface, away from tank walls, and remember the 25 cm blind zone when choosing its height.
Buy Here βπ οΈ Which Sensor for Which ESP32 Project?
| Project | Typical Distance | Best Pick |
|---|
| Robot car obstacle avoidance | 5 cm to 2 m | VL53L1X, HC-SR04, or 8×8 Matrix for direction |
| Water tank or sump level | 25 cm to 4 m | JSN-SR04T |
| Garage parking sensor | 0.3 to 3 m | TF-Luna or VL53L1X |
| Touchless switch or dispenser | Under 10 cm | Adafruit VL6180X |
| Doorway people counter, gestures | 0.5 to 2.5 m | DFRobot 8×8 Matrix ToF |
| Drone altitude, long hallway | Up to 12 m | TFmini-S |
| Outdoor gate, silo or pond level | Up to 40 m | TF02-Pro |
π Which One Should You Buy?
π
Just learning
The ELEGOO HC-SR04 pack plus a VL53L0X to compare sound and light.
π
Indoor smart home
The CQRobot VL53L1X for steady I2C readings up to 4 m.
π€
Robots and drones
The TF-Luna, or the TFmini-S for 12 m and faster updates.
π§οΈ
Outdoors and tanks
The JSN-SR04T for liquids, the TF02-Pro for long range.
β Frequently Asked Questions
Ultrasonic, ToF or LiDAR: which is best for ESP32?
Ultrasonic is cheapest and ignores colour and glass, but its beam is wide. ToF chips like the VL53L1X are small, I2C and accurate indoors up to a few metres. Single-point LiDAR like the TF-Luna gives the longest, steadiest readings with a narrow beam. Choose by range and environment.
Can I connect the HC-SR04 directly to an ESP32?
Power it from 5 V, and the trigger pin works fine from a 3.3 V GPIO. The echo pin outputs 5 V, though, so add a resistor divider (for example 1 kΞ© and 2 kΞ©) before the ESP32 input. Our HC-SR04 ESP-IDF tutorial shows the wiring and code.
How do I use several VL53L0X or VL53L1X sensors at once?
They all start at the same I2C address. Wire each sensor’s XSHUT pin to a separate GPIO, hold all but one in reset at boot, change its address in software, then release the next one. Alternatively use an I2C multiplexer.
Why are my readings wrong outdoors or on black surfaces?
Optical sensors measure reflected infrared light. Sunlight adds noise and dark or shiny targets return little light, so range shrinks and readings jump. Shade the sensor, average several readings, or switch to ultrasonic or the sunlight-tolerant TF02-Pro.
Is a distance sensor good for room presence detection?
For a doorway, desk chair or narrow spot, yes. To detect a still person anywhere in a room, an mmWave radar works better. See our mmWave presence sensors guide.
π Final Verdict: Best Distance Sensors for ESP32
The right sensor for each job:
For most ESP32 builds, the Benewake TF-Luna is the sensor to start with: 8 m of steady, narrow-beam readings on 3.3 V logic. Choose the CQRobot VL53L1X for compact indoor I2C sensing, the HC-SR04 pack for learning and robot cars, the VL6180X for touchless controls, the DFRobot 8×8 Matrix when you need direction as well as distance, and the JSN-SR04T or TF02-Pro for wet and outdoor jobs. For more parts, see our best sensors for ESP32 roundup, the ESP32 robot kits and motor drivers guide and our HC-SR04 with ESP32 ESP-IDF tutorial.
π¬ Not sure which sensor fits your project? Tell us what you’re measuring and how far away it is in the comments below, and we’ll point you to the right one.
All Amazon links above use our affiliate tag (esp32tutorials-20). Purchasing through them supports esp32tutorials.com at no extra cost to you. Prices and availability change frequently, so always confirm the current price on Amazon before buying.
We are a team of experienced Embedded Software Developers with skills in developing Embedded Linux, RTOS, and IoT products from scratch to deployment with a demonstrated history of working in the embedded software industry. Contact us for your projects: admin@esp32tutorials.com