### Motion Sensor (PIR) with ESP8266 and MQTT

#### Basics on Motion Sensor (PIR)

This simple chart below is the best I found to explain how PIR works:

This step covers the basics about part/form of PIR sensor, Arduino code to learn about the PIR, and a dedicated video to show what L setting looks like on the larger PIR version.

There are two (physical) forms of PIR sensors. One is smaller and looks simpler that costs about $1.28 on Aliexpress. The larger version (HC SR505) has two trimmer pots for the time delay and sensitivity setting, a jumper to select auto-trigger, and costs about$0.82 on Aliexpress. Both forms has an identical voltage regular (HT7133) and can accept the same input DC (max 24V, min ~5.0V). The typical current HT7133 output at 5.5V input is about 30mA, so soldering VCC wire to ESP8266 could overheat the IC. The ESP8266 consumes 100mA on average

The link to Adafruit has a detailed calculation of the time delay for the larger PIR version. For the larger version, the lowest (shortest) time delay setting relays HIGH status in 4-5 seconds after the last motion is detected. A half-way setting relays about 117- 120 seconds in HIGH status.

I was confused about H-L jumper on the larger version. If you are, watch the YouTube video about the L setup - or not auto trigger. With a jumper on L, the HIGH on Pinout only if there was a LOW period in between HIGH period. The smaller version does not come with this setup and has the only AUTO-TRIGGERING mode.

Below is the code I used to upload to an Arduino Nano:

void setup() {
Serial.begin(115200);
Serial.println("Starting");
pinMode(4, INPUT);  //Pin 4 <> the larger PIR
pinMode(5, INPUT);	//Pin 5 <> the smaller PIR
pinMode(2, OUTPUT);	//Pin 2 <> blue LED (indicates the status of the larger PIR)
pinMode(11, OUTPUT);  //Pin 11 <> red LED (indicates the status of the smaller PIR)

delay(1000);
}
int id = 0;
void loop() {
id++;
}