First ESPhome sensor - PIR stuck on

Tried making my first sensor today. Thought I’d start simple and just add a motion sensor, Then I’ll add lux and temp etc afterwards once I know it’s working. But my Motion sensor is ALWAYS showing motion?

I am using a ESP8266 - D1 mini
And a AM312 PIR.

PIR Pin: V = 5v Pin on D1 (have also tried 3.3v first - no change)
PIR Pin: Data = D4 Pin on D1
PIR Pin: G = G pin on D1

Wires are fairly long (25cm ish) as using Duponts.

Using the following code (the parts excluding name etc):

  board: d1_mini

  - platform: gpio
    pin: 2
    name: "Hall Motion"
    device_class: motion

I’ve tried pin: D4, And pin: GPIO2 too and still no luck.

Can anyone see what I’ve done wrong?
I literally have a box of different sensors and D1s next to me as planned to make one for each room today so I’m beyond disheartened at the moment…

Try another GPIO from the table here:ESP8266 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

D4 (GPIO2) is pulled high at boot and may be interfering with your sensor.

Thanks! It’s now in D5 and working correctly.

It is really twitchy though, it turns on for 2seconds, then turns off for 2 seconds, then back on for two while I wander around in front of it. It appears that my sensor has a 2 second update interval (I assumed that meant it can change from one state to another once per 2 seconds if required, but if its the same state it would persist).

Could I use the following to correct the behaviour?:

      - delayed_off: 2s

Or do filters only accept ‘ms’ periods?

Ignore me, found this:

1 Like

You might need to make it slightly longer than 2s to prevent glitching.

1 Like

Yeah I’m going for 2.1s

Thanks again for your help.