In this tutorial, we will use PIR sensor(human motion sensor) to imitate an intruder alarm system.
When PIR sensor detects motion, buzzer will make alarm beep sound and send intruder alarm message to remote APP. If alarm is triggered by home owner, then home owner can input a passcode to turn off the alarm. Or use a Cell phone APP to turn off the alarm.
First, please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:
Build the circuit as following picture:
PIR motion sensor — D6,
LCD —– I2C 1 Port
Keypad —– Keypad Port
If you haven’t install following libraries in previous lessons, please download and install them accordingly.
Programming Download and Installation:
Step 1 Download the code from following link, unzip it:
Step 2 After above operations are completed, connect OSOYOO MEGA2560 Board to PC with USB cable.
Step 3 Open Arduino IDE: Choose corresponding board type and port type for you project .
Step 4 Arduino IDE: Click file – Open, then choose code in the folder, load up the sketch onto your Arduino.
Note: In the sketch, find line following lines:
char ssid = "******"; // replace *** your network SSID (name) char pass = "******"; // replace *** your network password
please replace the ****** with your correct wifi SSID and password, otherwise your project can not connect to Internet.
Upload the sketch to the board. Wait until you see something like this:
After loading the sketch to OSOYOO Advanced Board for Arduino MEGA2560 , OPEN the serial monitor in the upper-right corner of IDE as following:
You will get the IP address and Port Number as following:
APP Installation and Setting:
Step 1) If you haven’t installed OSOYOO IoT Robot APP, please search OSOYOO IoT Robot Car APP in Google Play or Apple Store to install this APP.
You read following tutorial link for more information about APP install :
Step 2):Make sure your Cell phone is in the same Local Network of Arduino. Open the APP, click Settings, enter your Arduino IP address to Target IP Address field and Set Port to 8888 in settings:
Click Save, then go back to APP home page.
Now let imitate an intruder by put your hand close to the PIR sensor.
When PIR sensor detects objects, buzzer will alarm. At the same time, your APP will show intruder detected!
You have two option to close the buzzer Alarm:
Option 1) Enter a passcode 1234 which was defined in sketch file line 15 .
You can use keypad to enter 1234# (#means ending of the passcode input), after that buzzer will be turn off.
At the same time, LCD and APP will show “Passcode Correct”
Option 2)Press F8 key in APP to turn off buzzer alarm. APP will show “Buzzer closed by APP!”
|1||OSOYOO MEGA2560 Board||1||Click here to buy|
|2||OSOYOO MEGA-IoT Extension Board||1||Click here to buy|
|3||Photosensitive Sensor||1||Click here to buy|
|4||Temp & Hum Sensor||1||Click here to buy|
|5||OSOYOO Active Buzzer Module||1||Click here to buy|
|6||Flame Detection Sensor||1||Click here to buy|
|7||Fan Motor Module||1||Click here to buy|
|8||Micro Servo Motor||1||Click here to buy|
|9||RGB Module||1||Click here to buy|
|10||Ultrasonic Sensor||1||Click here to buy|
|11||PIR Motion Sensor||1||Click here to buy|
|12||Microphone Module||1||Click here to buy|
|13||1602 I2C LCD Screen||1||Click here to buy|
|14||RFID Module||1||Click here to buy|
|15||White LED Module||1||Click here to buy|
|16||Red LED Module||1||Click here to buy|
|17||Colorful Light||1||Click here to buy|
|18||Red Button Module||1||Click here to buy|
|19||Blue Button Module||1||Click here to buy|
|20||Philips Screwdriver||1||Click here to buy|
DownLoad Url osoyoo.com