This project is about security system including motion sensors which are generally used for detecting any intruder in confidential area. I've bought a course on IoT by BoltIot which provides me the medium to exercise different IoT solutions using their bolt Iot module. I've decided this as my project to explore the field of security based on IoT. This project gives you a small glimpse of the field of security that we can explore using the medium of IoT.
Problem Statement:We have to make a system which detects the motion of the object(Human or any other object) with the help of PIR (passive infrared radar), BoltIot Module and Telegram App.
If someone passes from the coverage area of the sensor then, sensor's output value becomes HIGH otherwise it remains LOW.
2. DemonstrationThe below video shows how the system works (Play it with sound on).
3. Circuit Explanation.Step 1: Take a PIR sensor and open the white lid above it.
Here you can see the VCC (for input), GND (ground), OUT (for output). Now connect jumper wires in all 3 ports.
Step 2: Take a bread board and connect resistor(330 ohms) and a LED as shown below.
Long leg of LED is connected with resistor.
Step 3: Now connect OUT pin of PIR with right leg of resistor, GND of PIR with short leg of LED and VCC pin in idle socket of bread board.
Step 4: Now take Bolt Wi-Fi module and connect jumper wires in it's 5V, GND & GPIO-0 port.
Step 5: Now connect Bolt's GPIO-0 to PIR's-OUT, Bolt's 5V to PIR's VCC & Bolt's GND to PIR's GND.
Step 6: Now connect Bolt wi-fi module through USB cable to your laptop and pair it with Wi-fi to access cloud.
The python code imports bolt library for connecting the code to our Bolt wifi module via bolt cloud. It also imports python libraries like "json"(to parse a string), "requests" (to make url request), "time" (for defining sleep function) and our own made package "api" in which we have defined our Bolt's API code, Device-id and out telegrams Bot-id and Chat-id.
After it we make an object of our bolt device by calling the constructor of class "Bolt" by "Bolt( APi-key, Device-id)".
Then we define a function to send the telegram message. In which we call the method of "requests" class by passsing request type (eg. "POST"), URL ( "Telegram Bot-id") and data ( "Telegram Chat-id and message"). We use "json" class's function "json.loads(string)" to parse the response string of the telegram.
Now we start a while loop, in which we take response from the "GPIO-0" pin of bolt module by the "Bolt" class's function ".digitalRead('0')" (only gives 2 values, 0 or 1). And then we parse our response by "json.loads(response)". If the sensor value is "1" which means motion is detected, so it calls the function to send telegram message. It takes the value of the sensor until an interrupt is generated by keyboard by pressing "CTRL+C".
OUTPUTThis is the output before sensor value is "1"
This is the output after the sensor value is "1".
Message of intruder alert on telegram.
So this was all about my project on PIR motion sensor using bolt module.
I hope that this explains all about it. If any query, you can ask below in comment section.
THANK YOU!
Comments