The basic principle of STM involves quantum tunneling, where electrons tunnel through the vacuum between the microscope's tip and the surface. By applying a voltage between the tip and the sample, electrons flow, creating a tunneling current. The current is exponentially dependent on the distance, allowing the microscope to detect variations in surface topography with high precision. The tip is raster-scanned across the surface, and the current is recorded to construct an image of the surface at the atomic scale.