The accuracy of the HC-SR04 sensor is typically within 3 mm, but it can vary depending on environmental conditions and the surface of the detected object.
The HC-SR04 emits an ultrasonic pulse and measures the time it takes for the echo to return. This time is used to calculate the distance to the object.