HCSR04 ultrasonic sensor example

Requirements

  • Hardware Requirements
    • 1 ESP32 or ESP32S3 flashed with EzloPi firmware
    • 1 HCSR04 ultrasonic sensor
    • 3 Jumper wires
  • Software Requirements
    • EzloPi desktop application
    • Vera mobile application

Circuit connection in ESP32

  1. HCSR04 ultrasonic echo pin
  2. HCSR04 ultrasonic trigger pin
ESP32

Adding HCSR04 ultrasonic sensor from EzloPi desktop application

  1. Connect the ESP32 to the computer and open the EzloPi desktop application.
  2. Scan, select and open the serial port, connecting to the ESP32.

3. Click on the ‘Add Device’ button as shown below.

Add Device ESP32
Connect the ESP32

4. Select the “other” option from the dropdown menu.

Select Option ESP32

5. Configure the HCSR04 Ultrasonic sensor:

  1. Give it a name. (“HCSR Ultrasonic” as an example)
  2. Select HCSR04 Ultrasonic sensor from the dropdown menu.
  3. Select the GPIO pin for the trigger
  4. Select the GPIO pin for echo
  5. Then click “OK”.
Configure the HCSR04

6. Device name, type, subtype and GPIOs are displayed on the screen; click on “set config” to burn the configurations to the ESP devices.
Finally, reset the device by clicking on “Restart”.

HCSR04 ultrasonic sensor in Vera Mobile Application

1. Login to the Vera app using username and password.

2. After login you should be able to see your controller online. The current controller shown has the serial 100004005. Make sure that after flashing the ezlopi firmware to the ESP32 device, you connect to the WiFi by clicking the Configure WiFi button in the UI

3. After the device gets online click on the controller icon as shown as it appears online. It will take some time to reload and add the device configured from the configurator UI.

4. The HCSR04 Ultrasonic sensor connected will be shown in the Devices’ panel.

5. If the sensor finds an obstacle in less than 500 cm distance the icon turns green

ESP32 Devices

6. If no obstacle is detected, the icon turns gray.

ESP32 Detected