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.
How Wemos D1 Mini works/what it is
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 PIR worksPassive 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 was being talked about.
One point to be noted is that as the name suggests, this is a passive sensor, that is, there is no transmission of any form of signals from the PIR itself. It only receives the transmitted infrared radiation from the outside world.The PIR sensor itself has two slots in it, each slot is made of a special material that is sensitive to IR. When the sensor is in an idle state, both the slots receive the same amount of ambient IR. But when humans or any warm body comes in front of the PIR, the first slot intercepts this change in IR levels and as a result a positive differential change between these slots is noted. As soon as the person moves across, the opposite happens, that is, the sensor generates a negative differential change. Due to these fluctuating IR levels, an alarm is triggered.
Now coming to the sensitivity part, PIR has a very commendable sensitivity of 7 meters and a delay time of 0.3s to 5 minutes. The delay time is the time considered when a body is in front of the sensor and stays there for a period of time. When the PIR triggers the alarm, it can trigger in two ways. There could be a repeatable trigger which implies that the alarm will be sounded off repeatedly and the non-repeatable trigger which only sounds off once.
So this PIR sensor can be considered as an ideal sensor for this circumstance as it is going to be used for motion detection.
How IFTTT worksIFTTT 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: https://ifttt.com/maker_webhooks 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.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.
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. The code can be found below.
// 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 = "maker.ifttt.com";
// Replace with your eventname and api key - open the documentation: https://ifttt.com/maker_webhooks
String event_name = "motion_triggered";
String api_key = "your_api_key_here";
String url = "/trigger/" + event_name + "/with/key/" + api_key;
Usage and applicationsThe 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.
ConclusionThe 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 email us at:
For more articles like this check The Tech Lab Website: www.thetechlab.webite
Our Facebook: https://www.facebook.com/thetechlab
Our YouTube channel: https://www.youtube.com/channel/UCjVpWA4bj87jjc26RGSX13Q
Comments