Wire the HC-SR04 ultrasonic sensor to the ESP32 as shown in the following schematic diagram. We’re connecting the Trig pin to GPIO 2 and the Echo pin to GPIO 1, but you can use any other suitable pins ...