Motion Detecting IoT Device

A simple motion detecting device that uses IFTTT to send a notifiication to user when it detects a motion.

The device built on a breadboard

Ethan began to slow his motions as he approached the locker. Any slight movement and he would give himself away. The entire museum was empty but there was one invisible obstacle preventing him from taking the gem-the MOTION SENSOR. Motion Sensor is used both in movies and in real life. You can also make yourself one at home. Want to know? Read below for the detailed explanation.

What is Wemos D1 Mini? How does it work?

The Wemos D1 Mini is an Arduino compatible microcontroller board with WiFi that packs a lot of features like low power mode, Bluetooth, I2C, SPI, UART etc. in a really compact package. We can program it just like an Arduino and it costs about the same as an Arduino UNO. But we get a lot more functionalities than a traditional Arduino UNO with some sacrifices like lesser pins. The reason it’s great for this project is because it’s really small and has ultra low power mode where it basically draws very little or no power at all making it a great for small battery powered projects like ours.

How does PIR work?

Passive Infrared Sensor

Passive Infrared Sensor or PIR in short is a sensor that detects electromagnetic radiation that is generated from the body of humans which is used as a trigger to sound off an alarm. So basically a PIR contains a particular lens which is called the “Fresnel Lens” that acts as the receiver for the PIR. In order to get a clear view of what a PIR sensor looks like, a picture of it has been given below. The white lens which is mounted on the right side is the Fresnel lens which we mentioned before.

Things Used in This Project

Hardware Components

Below is the given list of all the hardware components that are going to be required for this project:

  1. Wemos D1 Mini x1
  2. HC-SR501 PIR Motion Sensor x1
  3. Lithium Battery x1
  4. TP4056 Battery Charger x1
  5. Breadboard x1
  6. Jumper wires(generic) x1

Software Apps and Online Services

The following have been used for the completion of the project:

  • Arduino IDE
  • IFTTT Maker service

The Circuitry

The circuit for this project is actually really simple and you only need to assemble it on a breadboard using some jumper wires to test it. It mainly consists of a PIR sensor connected to our main processor, the Wemos D1 Mini. We also added a switch to manually turn the device on and off. The whole thing can be powered using a lithium battery as you see in the circuit diagram. However, for testing purposes, we can just power it from the USB port. We also add a TP4056 based battery charger module for easy charging of the device. It has battery protection features built in so our battery is safe from any sort of electrical damage.

How IFTTT Works

How IFTTT Works
How IFTTT Works

IFTTT derives its name from the programming conditional statement “if this, then that”. It is a platform that allows to connect applications, devices as well as services from various developers for the purpose of triggering one or multiple automations involving the use of the applications, devices and services. For the case of this motion sensor, IFTTT works in this manner. If this (the trigger is being activated while someone stays in front of the motion sensor), then that part (a notification gets sent to the mobile of the user) indicates that there is a person located up ahead at that very moment. So, this will allow the user to take actions accordingly.For our project, we use the webhook service of IFTTT to trigger an event, which then sends a message to our mobile phone. You can create the service by going to Sign up for a free account, use webhooks service in the “This” term and create a web request service. We name our event “motion_triggered”

In the “That” field, choose Android SMS → Send an SMS → Choose your SMS format. Note that sending SMS, your mobile phone carrier will charge money from your phone.

Now, go to the webhooks page: here and open the “Settings” tab. There should be an API key code that we will need later in the code. It’s good to keep it secret since it’s a code unique to your IFTTT account and service.



This is all there is to the schematic of this project. Easy right?

The Code

The code is actually pretty simple for the hardware that we are using, thanks to the amazing libraries. We commented the code with explanations of every section, so you can understand without having to Google around. Make sure to add your WiFi SSID, password, IFTTT event name and API key that we talked about above in the IFTTT step. Here is the part you have to edit in the code:

// Type your WiFi name (SSID) and password here:
const char* ssid = "your_ssid_here";
const char* password = "your_password_here";

const int httpsPort = 443;
const char* host = "";

// Replace with your eventname and api key - open the documentation:
String event_name = "motion_triggered";
String api_key = "your_api_key_here";
String url = "/trigger/" + event_name + "/with/key/" + api_key;

You can download the code from our GitHub Repository here:

Usage and Applications

The applications of this motion sensor are far and wide. It can be used at any point starting from fitting it in front of the main house gate to placing it in front of the stores at the malls. The use of the motion sensor can be even used to track down if an infant is staying inside the baby cot. This can easily be done by just tweaking the triggering system of the motion sensor. It is a versatile tool which can be used any place that requires monitoring.

The process is easier than you imagined, right? Now, you can also give Ethan a hard time. Tell us what you think in the comments below. Any questions? Shoot us an email at: