Distance sensors: Time of Flight /Lidar (vl53l0x) vs Ultrasonic (HC-SR04)

I’m tinkering with distance sensors using Esphome to measure the elevation of my DIY standing desk.

I had both some Time of Flight sensors and an ultrasonic sensor so I thought I’d put them side by side, and am sharing results in case someone cares:)

I thought the ToF sensor would be more reliable because it’s like newer tech and all, but it has much more measurement variability.

The desk height didn’t change in the below charts.

It’s more the variability that I’d be concerned about as you can’t really calibrate that away, just try to smooth it… Couldn’t do fancy variability stats quickly but it’s pretty clear in the histograms.

Also tossing up adding some endstop switches and/or maybe a rotary encoder in the spirit of overkill.

Thoughts anyone?