Well, this is yet-another motion sensor summary. A well-written tutorial from Adafruit is linked at the end of step 1. This tutorial is the part 2 on the topic of current limiting for LEDs, MQTT, and motion sensor. Part 1 is here.
PIR (Passive infrared sensor) or motion sensor is as its name implied detects a heat source that moves. Human, dog, cat moving across the front of the sensor triggers a HIGH signal. Here is a very nice diagram from Adafruit about the PIR sensor. PIR sensor is lost cost, and the response time is instant. The sensor can be configurated into several setups. Three setups covered in this writing included are:
Sensor and LED share a microcontroller such as an ESP8266 Separated sensor and other clients (light, database) communicates using MTTQ protocol Integrated with database and HTML to analyze the motion pattern with time stamp”