I made a vl53l1x time of flight (tof) sensor to count people with esphome

Can you please give us a wiring diagram

i’m not a programmer, which is the main reason that it’s not going to happen, that i write a native vl53l1x component thats working as a people counter. the other reason is, that theres no real incentive for doing that; the slightly hacky esphome setup that i documented in my repo is working really fine.

however, someone raised an issue here

that linked to an alternative algorithm that doesn’t require the proximity gesture library, which makes my custom implementation a bit easier. i have a working setup and prototype at home that seems to work much more reliable than the gesture detection. i’ll do some more testing and then update my repo with the simplified code on the basis of this idea.

Thanks for the reply. I’m also not a programmer and I’ve been playing with Home Assistant for a few months. I admit that I have no idea how to get your code into esphome. Could you please write the points so what and where to move? Thank you.

Hi,

This sounds very interesting, have you had any issues while testing? I also have VL53L1X so if you want additional testers I’m happy to help.

please help me
i played esphome and connected sensor
I do not get the result
I connected XSHUT pin to D5

I used wemos d1 mini
SCL - D1
SDA - D2
XSHUT - D3

thank you very much

please help me
I play klo
and report such error and cannot connect to wifi

Please don’t post pictures of text files, that is ridiculous.

What is your yaml?

here is my configuration

esphome:
name: klo
platform: ESP8266
board: nodemcuv2
includes:
- tof/tof_vl53l1x.h
libraries:
- “VL53L1x”

i2c:

switch:

  • platform: restart
    name: $friendly_name Restart

todo template switch to turn offf measurements

  • platform: template
    name: “tof Sensor-Status”
    id: tof_sensor_status
    icon: “mdi:toggle-switch”
    lambda: |-
    if (id(tof_sensor_status_state).state) {
    return true;
    } else {
    return false;
    }
    turn_on_action:
    • binary_sensor.template.publish:
      id: tof_sensor_status_state
      state: ON
      turn_off_action:
    • binary_sensor.template.publish:
      id: tof_sensor_status_state
      state: OFF

binary_sensor:

  • platform: status
    name: $friendly_name Status
  • platform: template
    name: “tof sensor status state”
    id: tof_sensor_status_state
    internal: true

sensor:

  • platform: wifi_signal
    name: $friendly_name RSSI
    update_interval: 60s

  • platform: uptime
    name: $friendly_name Uptime
    id: uptime_s
    update_interval: 30s

https://github.com/jardous/tof_vl53l1x

  • platform: custom
    lambda: |-
    auto my_sensor = new MyCustomSensor();
    App.register_component(my_sensor);
    return {my_sensor};
    sensors:

    • name: Distance raw
      id: distance_raw
      accuracy_decimals: 0
      unit_of_measurement: “mm”
      internal: true
      on_value:
      if:
      condition:
      # Same syntax for is_off
      switch.is_on: tof_sensor_status
      then:
      - sensor.template.publish:
      id: distance_filtered
      #state: 42.0
      state: !lambda ‘return id(distance_raw).state;’
      - sensor.template.publish:
      id: distance
      #state: 42.0
      state: !lambda ‘return id(distance_raw).state;’
  • platform: template
    name: Distance filtered
    id: distance_filtered
    accuracy_decimals: 0
    unit_of_measurement: “mm”
    icon: “mdi:ruler”
    filters:

    • sliding_window_moving_average:
      window_size: 10
      send_every: 5
    • delta: 5.0
    • heartbeat: 60s
  • platform: template
    name: Distance
    id: distance
    accuracy_decimals: 0
    unit_of_measurement: “mm”
    icon: “mdi:ruler”
    #device_class: None
    filters:

    • delta: 10
  • platform: template
    name: Timeouts
    id: timeouts
    accuracy_decimals: 0
    unit_of_measurement: “Stk”
    #device_class: None
    icon: “mdi:alert-circle”
    update_interval: 60s
    lambda: |-
    return num_timeouts;

Please read and implement the suggestions here, especially how to format your code properly.

Is there a way to alter the distance(or percentage) an object is declared as entry or not?
I’ve found I’m consistently recognised by the counter, but the wife is not. I’m 1.93m and the wife 1.73. As I’ve read around, the default is about 80%, which makes sense, but I haven’t found anywhere how to alter that. I’m talking about the tof_people_counter

Hi
please help me when i make on esp8266
then this error occurs but when i do it on esp32
works perfect
according to file klo.yaml
I guess it’s because the config file is supporting esp32
not esp8266
Can someone help me fix the esp8266?
Print the file included from /data/toilet_smart/.piolibdeps/toilet_smart/ESPAsyncWebServer-esphome/src/SPIFFSEditor.cpp:1:0:
/data/toilet_smart/.piolibdeps/toilet_smart/ESPAsyncWebServer-esphome/src/SPIFFSEditor.h:16:101: warning: ‘SPIFFS’ is deprecated (declared at /root/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/ FS.h:269): SPIFFS has been deprecated. Please consider moving to LittleFS or other filesystems. [-Wdeprecated-declarations]
SPIFFSEditor(const String& username=String(), const String& password=String(), const fs::FS& fs=SPIFFS);

Please post (with proper quoting) your esphome yaml file and your log.

The SPIFFS deprecation message comes up on all my builds and everything still works.

Another try on this forum because I am really keen on trying this with esphome but not receviing any reaction on github.

  1. Ready to try, config ready, but 1 question · Issue #5 · diplix/esphome-configuration · GitHub
  2. Help with setup · Issue #2 · diplix/esphome-configuration · GitHub

So, does anyone use this one? I use it but I find that the “beam” of the sensor is too narrow. The width of my doors is around 70-80cm and if I put it on the center at the top, it doesn’t consistently mark entry or exit due to someone entering on the side, whereas if I put it on the side, if someone comes from the other side, same thing. And this seems if not the best, one of the top (for me)methods to calculate actual people on a room.

I am using a similar logic modified to operate on a battery.

Hmmm that’s weird. If I put mine on the side, it doesn’t detect me when passing. I thought it had to do with “seeing” the other side of the door at a close distance. If I put it on top of the door, it detects me only if I pass directly below it.
I’ll check again what’s going on

Can you please share the procedure how to put this sensor into operation in ESPhome?

I share my esphome code
Download the file from the link below

https://cafe.naver.com/koreassistant/3435