running into an issue getting a PIR sensor to run on my esp8266 d1, same sensor and code runs fine on an esp32 wroom. on the ESP8266 the PIR sensor is always off. i have also tried different pins (D2, D1, D5, D7) all with basically the same result. Same PIR sensor work on the ESp32 so its not a dead module.
Depends of point of view. To you it’s obvious the problem is in code because sensor is same. To me, since you have tried all the pins available and your code is just simply reading digital input, even before I have a look at the code I prefer to verify hardware. In this case there’s nothing popping up, but if your sensor was rated for 3.3V-x.xV voltage, it could have been something to verify. And I still expect you have hardware problem.
Have a look at the log, is your pin state changing there?
Have you got a multimeter to measure the voltage at the gpio whilst connected to the ESP in both triggered/non-triggered state? Would be interesting to know the levels you are getting. You are looking for something below about 0.8v for a low and above about 2.5v for a high. If you are getting something around 1.65v for either state you may get different readings between ESPs due to manufacturing differences in them.
Long shot, but given the code & sensor are the same, that only leaves the board.
I suspect you have a floating pin. Have you tried setting the pin as pull-up or pull-down in code? There’s a few examples of this in the Esphome docs, but I don’t have a link handy right now