Motion Sensor (PIR) with ESP8266 and MQTT


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:

  1. Sensor and LED share a microcontroller such as an ESP8266
  2. Separated sensor and other clients (light, database) communicates using MTTQ protocol
  3. Integrated with database and HTML to analyze the motion pattern with time stamp

Here is what we are working. A motion sensor signal is sent by ESP8266 wirelessly, and the data is used to turn on/off a light or a SQL database.