# Complete project details at https://RandomNerdTutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/
from hcsr04 import HCSR04
from time import sleep
# ESP32
sensor = HCSR04(trigger_pin=5, echo_pin=18, echo_timeout_us=30000)
# ESP8266
#sensor = HCSR04(trigger_pin=12, echo_pin=14, echo_timeout_us=10000)
while True:
    distance = sensor.distance_cm()
    print('Distance:', distance, 'cm')
    sleep(1)