Building a Tiny, ESP32-Powered Laser Rangefinder

This device packs an ESP32, lidar module, and LiPo into a single quarter-sized footprint and can measure objects up to two meters away.

The value of rangefinding

After getting one of the smallest OLEDs available, measuring in at a mere 0.49 inches diagonally and with a resolution of 64x32 pixels, pseudonymous developer "gokux" was looking for a practical application that could make use of it. Ultimately, this concept of a tiny display within a mobile device evolved into an ultra-compact laser rangefinder, as one could provide a user with accurate distance measurements up to two meters away and aid in a variety of scenarios such as fabrication or photography.


To build it, gokux first had to gather several small components that could all be crammed into a tiny enclosure. For the microcontroller, he went with a Seeed Studio XIAO ESP32C3 since its fast processor would be able to quickly display graphics on the 0.49inch OLED module. Distance sensing is provided via a VL53L0X time-of-flight (ToF) sensor, which works by emitting a laser beam and measuring how long it takes to see a reflection. Lastly, a slide switch was added to cut or allow power from LiPo battery cell to the rest of the circuit.

Design and assembly

The process for designing the final enclosure was quite time-intensive since gokux had to test a variety of configurations for his components until he reached an optimal layout. But once the best solution was found, he was able to build the case around the arrangement of parts while taking care to provide openings for the USB-C port, display module, and power switch. A few hours of 3D printing and soldering later, gokux had finished assembling his miniature device with the help of some glue.

Showing the distance

Overall, the code running on the ESP32 is quite straightforward. It starts by initializing the OLED's driver and the VL53L0X lidar module before entering into the main loop. From here, the range is sensed for up to 200ms and then passed into a median filtering algorithm that helps smooth any outlying results. Finally, the resulting distance is printed to the OLED. For more information about this very compact laser rangefinder, you can read gokux's write-up here on Instructables.

Evan Rust
IoT, web, and embedded systems enthusiast. Contact me for product reviews or custom project requests.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles