You just need to use the above code. The PIR code is needed if you are attaching HC-SR501 sensor to the board. Also note that neither one of them are perfect and have their pros and cons.
The RCWL-0516 passes through obstructions like walls, doors etc and can create false positives in certain situations.
Just wanted to say thanks @PanMat - I recieved a 5 pack of these sensors today, wired one directly to a D1mini (no cap or extra resister) and it works perfectly, the range is approx 4 meters. Perfect for a room based multi-sensor.
For reference, we can get the current value of the sensor by soldering a wire to one of the legs of this IC and inputting it to A0. This makes it possible to adjust the sensitivity to some extent by setting the threshold.
Wiring position, It is the fifth leg from the top on the right side of the image. (I used 0.2mm Enamel Wire (Polyurethane Copper Wire).)
For all those who still have the problem that the sensor is permanently “on”: Take a look at the voltage (Vin). I had accidentally applied only 3.3V instead of 5V, so of course the sensor didn’t react…