How to auto-zero the z-axis using a high-precision distance sensor?

It’s not my idea. It’s the approach described in this Wiki post: Automating z-axis zeroing

WebControl added the touch-plate feature to support this approach.