Vibration sensor doesnt "clear" sometimes

I have a SW-420 vibration sensor. When powered one light is always on. When it detects vibration another light goes on, then goes off when it “clears”.
About half the time it just doesnt “clear” even though all vibration has clearly stopped (and the second light goes out)

Any advice?

yaml is:

esphome:
name: bandsaw-vibration
friendly_name: Bandsaw vibration

esp8266:
board: esp01_1m

Enable logging

logger:

Enable Home Assistant API

api:
encryption:
key: zzz"

ota:

  • platform: esphome
    password: “yyy”

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

  # Optional manual IP

manual_ip:
static_ip: 192.168.2.24
gateway: 192.168.2.1
subnet: 255.255.255.0

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “Bandsaw-Vibration”
password: “xxxxx”

captive_portal:

binary_sensor:

  • platform: gpio
    pin:
    number: GPIO4
    mode: INPUT_PULLUP
    name: “Bandsaw Vibration Sensor”
    device_class: vibration
    filters:
    • delayed_on: 10ms
    • delayed_off: 1000ms

I don’t have your specific sensor, but I expect it to output low for vibration and high when stable. So if you don’t invert your binary sensor, your delayed on/off are working as opposite.

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO4
      inverted: true
......

Also, the module has probably pullup, so you likely don’t need it on your binary sensor pin conf.

And lastly, since esp01_1m doesn’t have Gpio4 exposed, you likely have wrong board definition.

Thanks Karosm for the very thorough and informative response!

I’ll start by saying i’m reusing code from a youtube project I found. I purchased these chips:

They say they are " This is D1 mini, it is a mini NodeMcu Lua WiFi board based on ESP-8266EX."
Not much other info on them. I’ve tried a couple of different board definitions. This seemed to work.

I’ll invert the sensor, but the delayed on off shouldn’t really be a problem, at worst it would wait a second before turning on, etc.

Esphome/ha show it sometimes clears, and sometimes remains in ‘detected’ mode even though there is absolutely no vibration.

Then use:

esp8266:
  board: d1_mini

Your board has 4MB flash, defining esp01_1m is using only 1MB and eventually causing problems.

Invert, remove pullup and filters and verify your sensor LED and esphome binary sensor work in synch. Then add the filters as needed.

Also, the sensitivity potentiometer might need adjustment.

Thanks, I think this has helped.

I’ll keep checking it throughout the day.

I greatly appreciate your input!

I spoke too soon, still having the same issue>

yaml is now:

esphome:
  name: bandsaw-vibration
  friendly_name: Bandsaw vibration

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "sd"

ota:
  - platform: esphome
    password: "sdfsf"



wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

      # Optional manual IP
  manual_ip:
    static_ip: 192.168.2.24
    gateway: 192.168.2.1
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Bandsaw-Vibration"
    password: "sdfsf"

captive_portal:

binary_sensor:
  - platform: gpio
    pin: 
      number: GPIO4
      inverted: true
     
    name: "Bandsaw Vibration Sensor"
    device_class: vibration
    filters:
      - delayed_on: 10ms
      - delayed_off: 1000ms

Remove the filters and post what’s exactly the behavior.
Do you have voltage/multimeter?

I removed the filters, same behavior (still reads ‘detected’)
I have a multimeter.

On esphome or in home assistant?
Did you look at esphome logs?

Toi verify voltage, disconnect data output between sensor and esp. Measure voltage between sensor gnd and output while still and while vibrated (LED on)

I have it set at the lowest possible sensitivity setting. It I turn it all the way clockwise, both lights are lit and it remains ‘detected’ permanently. If I turn it all the way anticlockwise, it will go off and report clear.
Current behavior - one light always on.
If I shake it second light comes on, it reads ‘detected’
Now one of two things happens - once it stops moving it either remains with both lights on (detected) or one light goes off and it behaves correctly.
If it remains with both lights on if I tap it with a pencil - even the slightest tap - , the light will then go off and it moves to clear.
This issue repeats.

the wifi signal is -27db

That translates to sensor problem. Did you try to position sensor differently?
Your original post gave me misleading picture of the problem.