Finding a reasonably priced distance sensor
19 April 2026 at 5:50 pm
For a new product, I'm making a very simple IoT distance sensor. Initially I thought this whould be a quick project, but finding the right sensor proved more difficult than expected. This is what I learned from the project.
One of my colleagues at Bitraf have a product where he needs to measure distance with reasonable precision and report that back to the user. The device needs to be battery powered, so very low power usage in Deep Sleep is a must. And of course - the battery needs to be charged easily. This sounds like something that could be useful for many, so I spun up a quick board based on an ESP32 C3 mini module and the VNCL4020 distance sensor from Vishay.
Attempt 1: Vishay VNCL4040
Once the first board arrived, I worked around a couple basic errors and then got to work on getting data from the VNCL4040 sensor. The light sensor worked consistently, but the distance sensor was not very precise? When diving into DeepSleep and coming back up again, the device would report slightly different numbers. I 3D printed a jig to confirm this and it showed that despite having the exactly same distance, the results were off in some of the readings. That really surprised me, but that'l likely why Adafruit only writes that the sensor has ‘reasonable accuracy’ in their guide for the breakout. I got about a centimeter accuracy out of it. If it only had been consistent that could have worked. I had expected this sensor to be more solid. Oh well. I'll try again!
Attempt 2: Sharp GP2AP03VT00F
Next I looked around for other sensors in a similar form factor at a good price and I found the GP2AP03VT00F. Looking at the datasheet, it seemed to do have the precision that was needed, but there wasn't many pre-written libraries online. Looking at the datasheet, I understood why. It hardly holds any data and the protocol wasn't documented at all. I thus sent them an email via their website to ask for a full datasheet and started designing the new PCB. I also found a design on Tindie by one of the library authors, so I ordered a couple breakout boards from him.
The breakout boards arrived just a few days later. Boy was I disappointed once I got the breakout board up and running? The Sharp website claims that the accuracy of the GP2AP03VT00F ±6% when measuring at 10 cm. That is absolute horseshit. The resolution and repeatability is extremely poor and the range is based on extremely ideal conditions. It ranges in two ranges - near and far. In the far mode, the precision is less than a meter. In near mode it is less than 2 cm.
I never heard back from Sharp. I'm sure that the library I used has been made as good as is possible, but if Sharp is incapable of publishing the datasheet, there might be inaccuracies related to that. Why would a vendor NOT publish the datasheet? Just to make it as easy as possible to succeed with their product? So when my board arrived a few days later, I knew that I would be disappointed. The absolute lack of response/support make me (as a hardware designer) want to avoid ever using parts from Sharp ever again. Using parts from Sharp is also made harder by the fact that Sharp is much more than sensors. Looking online, it seems that making printers & screens is their primary focus these days?
Attempt 3: ST VL53L4CD
Having spent too much time on this, I now wanted something that “just worked”. I spent time digging around and found a good candidate from ST Micro called VL53L4CDV0DH. I've never had problems finding the information I need when working with their parts and the VL53 series appeared to have a good track record. Price-wise this sensor was more expensive, but given a decent volume it wasn't all too bad. Getting it up and running was very smooth and the precision was super-solid. It'll precsisely detect from 30-1300mm. Why is this so much better?
The former two sensors both use infrared light. This is fairly cheap due to the volume of IR diodes being made, but a major drawback is that they're affected by external light as well. The ST sensor is using a tiny 940 nm invisible laser instead. This provides much more solid detection in the same size package. It is quite common to have to do multiple iterations on products, but the lack of precision from well known vendors is what puzzled me most in this case.
My plan for the product
Currently, a little more testing is required before I have the final firmware. I'm using my Joulescope to optimize the power consumption as much as possible. My target is to make the device run for at least 3 months on a single charge when using a 1200mAh cell. Hopefully even longer. Using a bigger battery, you'll easily get a year plus out of it. The trick is of course to balance the frequency of reporting with battery consumption, but I'll make this easily configurable.
The board is tiny for a bettery operated IoT device, measuring just 35 by 30 mm. The PCB shape makes it easy to put it the correct way into a product and secure it. I'll sell it as a product on Maketronics, just like the RadSense. I'll also sell it to OEM's with a need for distance sensing and I have the first customer ready to go. The board has builtin battery charging, battery sensing, battery cutoff, USB detection and a buzzer. The firmware will be open and I'll provide schematics for documentation & ease of repair. Any single cell lipo can be used and I'll provide a basic 3D printable enclosure for a decent sized battery and the PCB itself.
I have a couple other sensor boards in the works as well, but since I currently work 50% for Roest, I don't have too much time for my own products. Most of my other time is spent on making Bitraf run and serving a select few external customers. These are mostly return customers with longer projects, but I'm currently doing some fun things in medical as well. Good times overall!