Sensors for measuring distance (preferable Zigbee)

Hello,

I’m looking for sensors which could measure and report distance.

I can think of several use-cases, for example measuring the available space in my dust bins or the water-level in a rainwater barrel or in a cistern.

Would prefer Zigbee, because I got no WiFi-signal at the location yet. But I couldn’t find anything in this direction, perhaps someone knows some manufacturer which produces such sensors?

Otherwise I would try to use WiFi instead, are there any recommendations?

I don’t believe the protocols cover this. Zigbee, for example, does signal strength. That is determined by more than distance. It also has to do with obstructions.

To get real distance, each device would have to have GPS abilities.

Not sure about dust bins. But, water barrels could be handled by float switches. Not sure if there are any Zigbee float switches, but that would be a good search I believe.

are you looking for an already built sensor or just ideas?
what range are you looking for?
i’m using a VL53L0X to check the level of cat food in my custome made feeder, it should sense up to 2 meters… but you need to build a device for it to work :slight_smile:

A long time ago I built something similar to this; for me, it measures the distance from my garage ceiling to the object (or lack thereof) below so I could check if my car is in the garage or not:
Wemos D1 Mini and HC SR04 Ultrasonic Sensor · RTurala/Sonoff-Tasmota Wiki · GitHub

But it uses a D1 Mini and therefore is connected to my WiFi.

I would like to convert it to ESPHome but haven’t found the right instructions and time yet.

Thanks for your replies!

To get real distance, each device would have to have GPS abilities.

Sorry for being unclear: I mean measuring the distance from the sensor to an object or surface, so something like this:
https://de.aliexpress.com/item/1005005596117675.html
but with a way to connect to HA.

are you looking for an already built sensor or just ideas?

An already built sensor would be fine. I think a distance from 0m to 2m or 3m would be fine for most cases.

A long time ago I built something similar to this;… But it uses a D1 Mini and therefore is connected to my WiFi.

Yea, something like this would be fine. So perhaps I’m trying to find a solution with ESPHome somehow, if there is really no “buy and use” sensor available.

I was just wondering why no manufacturer seems to offer such a sensor - it seems to me very usefull.

All good. I get it now. Makes sense!

Just came across this - haven’t read all the details yet, and need to do that before I try to replace my current solution with this; seems to be rather straightforward though:
HC-SR04 & JSN-SR04T ultrasonic distance sensors in ESPHome | Markus Haack // Software Engineer (markus-haack.com)

1 Like

Hey @Cangoou, did you ever manage to implement the solution on ESPHome?

Unfortunately not yet, still got other projects in the pipe :wink:

As it was a cold & rainy day today, I finally converted the Tasmota sensor to an ESPHome one; the instructions in the above link worked fine in general, but had to make a few adjustments due to error messages and incorrect results.
This is what I ended up adding at the end of the code that was auto-generated by ESPHome after I added the Wemos D1 Mini to it:

sensor:
 - platform: ultrasonic
   trigger_pin: GPIO13
   echo_pin: GPIO12
   name: 'Garage Distance Meter'
   update_interval: 5s
   accuracy_decimals: 1
   unit_of_measurement: cm
   filters:
   - lambda: return (x * 100);

The original code used the D-numbers for the pins, I had to change them to the GPIO numbers and add a multiplication filter to actually get result in cm.
The original update_interval of 1s worked but I don’t need it updated that often.

Another thing I noticed was that when using Tasmota the distance sensor seemed to easily recognize distances above 2m (up to 4m, I think), now it seems to show ‘unknown’ as soon as I get close to 1.8m.
As the sensor is installed higher than that, it will show ‘unknown’ when the car is removed from underneath it, so I had to change the ‘standard’ float(0) I used to use to this in the template sensor:

  - sensor:
      - name: Garage Status
        unique_id: 'garage_status'
        state: >
          {% if states('sensor.garage_distance_meter') | float(999) > 100 %}
            Garage Empty
          {% else %}
            Car in Garage
          {% endif %}
        icon: >
          {% if states('sensor.garage_distance_meter') | float(999) > 100 %}
            mdi:garage-alert
          {% else %}
            mdi:garage-variant
          {% endif %}
1 Like

There is a a Zigbee solution

the LD2410 is a presence detection sensor that can measure distance too.
AliExpress sells Wifi or Zigbee versions.