Making a cheap alarm with web notifications through IFTTT is relatively simple with a passive infrared motion sensor (PIR) such as HC-SR501 and an esp8266.

You can install a few of these and monitor your home or office (provided power and WiFi of course). Future expansions could include a SIM GPRS module for SMS alarm messages.

The HC-SR501 module is one of the most common sold for Arduino/IoT based installments. Here’s a nice blog post describing a lot of interesting things about this sensor: http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-hc-sr501-motion-sensor-tutorial/

Problem #1:

As most this kind of sensor requires 5v to work reliably. In 3.3v it is proven that gives false positives or no detection of movement. So in a setup with esp8266 (or a NodeMCU board like I used) you must have a 5v output just for the PIR sensor.

Thankfully someone has found a solution without modifying the sensor as most propose (this is tested for the sensor working in repeat mode). Studying the schematics it is shown that instead of connecting the 5v power to the standard VDC input you can connect 3.3v directly to the lower pin of the High/Low trigger selection pin. You can read about this in the following blog post https://techgurka.blogspot.gr/2013/05/cheap-pyroelectric-infrared-pir-motion.html

Problem #2:

Interference! PIR sensor acts crazy when in close proximity with esp8266/NodeMCU’s WiFi producing a lot of false alarms.

The solution is to put the WiFi of esp8266 to sleep until there is a movement trigger from the sensor with this code:

void stopWiFiAndSleep() { WiFi.disconnect(); WiFi.mode(WIFI_OFF); WiFi.forceSleepBegin(); delay(1); }

Problem solved!

As mentioned you’ll need an IFTTT account and a webhooks (former maker) key to use in the code. So each time PIR sensor detects motion esp8266 connects to WiFi and fires a webhook event. For example a Pushbullet notification in your phone.

The schematic connecting PIR with a NodeMCU is the following:

An ON/OFF switch is also added to stop sending the alarms when needed.

The code for the above setup is uploaded here: https://github.com/nikant/PIR-ESP-ALARM