Ultrasonic Sensor HS-SR04 Distance Limitations

Hello,

Firstly, im new to all subjects discussed here;

  1. NodeMCU - playing with just my second one, the first I used about 2 weeks ago and its now running WLED.
  2. Ultrasonic Sensor HS-SR04 - first time today
  3. Arduino - installed for first time today.
  4. ESPHome - install for the first time today

With the help few videos, ive got the sensor into HA using ESPHome and its reporting distances correctly up to 1.6m.

However, in my learning curve today, I also installed Arduino and when I uploaded that to the NodeMCU, in the serial port I was able to successfully read distances over 2.5m away!!

For my project, I need to be able to read about 2m - so am I just doing something wrong on the ESP side of things to not get the same long distance readings as I get in Arduino?

My sensor is;

sensor:
  - platform: ultrasonic
    trigger_pin: D4
    echo_pin: D3
    name: esp_hallway_stairs_ultrasonic
    update_interval: 500ms

Thanks in advance

Just to say ive fixed my own problem.

There were advanced options for the sensor in ESP which I hadnt realised so were set at default;

  • timeout ( Optional , float): The number of meters for the timeout. Most sensors can only sense up to 2 meters. Defaults to 2 meters.
  • pulse_time ( Optional , Time): The duration for which the trigger pin will be active. Defaults to 10us .

Im not sure why I was only getting 1.6m (rather than the default 2m), but I edited the timeout option to be 3.0 and now Im able to get readings up to 2.5m like I was in Arduino.

All in all, a good days learning.