Blog

Blog

Uncategorized

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.

Schematic

Schematics

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 = "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;

You can download the code from our GitHub Repository here: https://github.com/TheTechLabRND/Arduino-Projects-Code/blob/master/Motion_detector_IOT_device.ino

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:

Articles

Scribble Pad: The idea that was born while disrupting…

Sameen demonstrating and talking about his software.

Hello there reader! My name is Sameen, the developer of Scribble Pad. I’m currently enrolled under Education Programme. I have created this software with the help of my teacher, Noor. It might not be in the best shape just yet, but soon you can hope for it! Now, as I had promised, let’s talk about the software and some background info.

Background story

At our institution, we were given a task of making a game, or a software, as the final assignment of Level 2. From a young age, I have always been fond of games. So I didn’t think twice before choosing to make a game. The tough part was deciding which kind of game I would make. It took me about a day to come up with the idea to make a game similar to “Crossy Road” (this is before Scribble Pad and the COVID-19 outbreak). I started very quickly, and my progress was fast. The basic outline of the game I finished in about 3 weeks. Few other members were also making games in our class (basically a competition on who could make the best app).

COVID-19 Pandemic.

But as the virus spread out in Bangladesh, I was left in dismay. This was mainly because I forgot to copy my game onto a Pen Drive and it was left in the campus which had got closed due to the outbreak. I also didn’t start over with making the game because I felt lazy and unmotivated to rewrite 400 lines of code! As a result, I felt like I needed a substitution!

The Rise

Online class going on.

Around this time, our teacher had also changed and this time, it was Noor. I was thoroughly depressed because my game was lost and my hard work had gone to waste. But he gave me hope. So our classes were taken on the Zoom App, and honestly, I loved drawing on the screen in the app and disturbing my teacher! As he was giving us a lecture and, I was obviously scribbling on the board, I came up with an idea. Why not make an app to draw?! This wasn’t only it (by the way, I was not paying attention to his lecture, I was in my own world!) I thought that in Zoom teachers mainly used virtual boards to teach, so why not make an app to help these teachers?! As many people were deprived from learning from boards in this coronavirus period, my software would come to the perfect aid. And that’s where all this started and Scribble Pad rose

The Start and End

As I got started with this software, I realized it was going to be hard to build this software. I was a newcomer to the Processing software , so even making this simple software was quite hard. Nevertheless, my teacher was always there to help me. As a result the game was successful. There were some hard times with the code but I was able to overcome this. A very interesting thing was, I got stuck in my code quite a few times, and I was pretty sure I had written the code correctly, but to my surprise, the function was not being carried out properly. But as I was about to show him these problems, the code somehow started working perfectly fine.

A screenshot of the software.

This led me to the conclusion that even the codes respected Noor! Sometimes my brother Shabab, who’s also a student at The Tech Lab, helped me too. When the submission date was given it was nothing special to me since the usual me would always finish the project the night before submission and this time it was nothing different! But anyway, I was able to finish my game with success and that was the biggest relief and excitement for me, as I knew my work had not gone to waste!

Yes, the color of pencil and background can be changed too!

You may have used my software, it may seem a bit buggy at times, but we, at The Tech Lab, have put a lot of effort into making this software. So, like all other app builders have, our only request is, ENJOY!

You may try Scribble Pad here.

Credits section.

P.S. You can find more details about the Scribble Pad in the software “Credits” section!

Articles

First post!

Welcome to our new blog! From now on, we would be posting fun projects, tutorials, ideas and a lot of other cool stuff here. Stay tuned!

#TheTechLab

#EngineeringForEveryone