

I drilled a small hole in the base of the box alighned to the top of the pot, I can slip in a small screw driver to adjust the sensor rage without having to remove the lid. Mounted on a scrap piece of timber so that the door frame blockes the sensor when the door is open. I mounted the sensor in a small, clear jiffy box (clear so that I can see my handiwork!). You will find this with many Arduino sketchs, pin mapping varies depeong on the board you are using. So GPiO pin 0 (referred to in the sketch), actually breaks out as WEMOS D1 Mini pin D3. The D1 Mini is effectively just a shield, the sketch actually just runs on the ESP8266. This is because the D! Mini is based on the ESP8266 chip/processor. *NOTE: The sketch defines the sensor as Pin 0 - however it is physically connected to WEMOS D1 Mini pin D3. When mounting in the box I drilled the holes for the LEDs very carefully to make a snug fit for the LEDs - there is no need for additional adhesive which makes removal for adjustment, mounting etc easy. You can easily reverse this to suit your need depending where you mount the sensor in relation to the door position. The sketch is written so that the pin is set HIGH when the door is open (the sensor is blocked), or LOW when the door is closed (senor not blocked). I set it to about 5cm which is ample to allow for variations in the door when open. Run the sketch and check the serial monitor to see that the value on pin D3 changes when you block the front of the senor (in front of the LEDs) - you can change the detection distance by adjusting the potentiometer (pot).
