IoT IR-Driven Security Alarm
Overview
The IoT IR-Driven Security Alarm is an mbed-based system that uses an IR sensor to trigger a multi-stage alarm response. When the IR sensor detects an object for 5 seconds, the alarm sequence begins. The speaker begins to sound an alarm, the RGB LED begins to illuminate red, the LCD reports the alarm has been triggered, and the mbed sends text message alerts to specified recipients. The user must enter a code to deactivate the alarm. This system incorporates mbed programming as well as web programming and the configuration of a web server. The mbed incorporates a real time operating system, and six threads are used for coordinating the system. Two threads share the uLCD, so a mutex is used to prevent conflicts in accessing the display.
Demo
Photos
Web Component
The mbed relies on an external web server to send text message alerts. This project uses a PHP script, which requires the PHP sendmail module. Instructions for setting up a PHP web server on Linux are available at https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu. The MySQL server is not required for this project.
The script requires configuring an authorization code that the mbed sends to the web server. The authorization code must be configured the same on the web server and on the mbed. Additionally, the message recipients need to be configured on the web server. The $authcode variable stores the authorization code, and the $recipients array contains the message recipients. The authcode is provided by the mbed in the form "alert.php?authcode=AUTHCODEVALUE" in the HTTP GET request from the TCP code. For more information on HTTP GET requests and query strings, see http://www.w3schools.com/tags/ref_httpmethods.asp. The SMS recipients are in the form of email addresses in the format 10digitphonenumber@sms.gateway. The SMS gateway is determined by the carrier associated with the phone number. A complete list of SMS gateways is available at http://www.emailtextmessages.com/. The script below should be stored as alert.php in a publicly accessible web directory, such that it can be accessed by a URL from any Internet-connected device. The code below uses an authorization code of "12345" and sends alerts to the AT&T number (555) 555-5555 and the T-Mobile number (555) 555-5554.
PHP script for sending text alerts
<?php // Sends an alert to recipients // // Required query strings: // - authcode: the authentication code defined below $DEBUG = 0; // if enabled, no messages are sent $authcode = "12345"; // set authentication code that is passed through the "authcode" query string $recipients = array("5555555555@txt.att.net", "5555555554@tmomail.net"); // message recipients $subject = 'Alert!'; $message = 'An alert has been triggered!'; $headers = 'From: mbed@example.com' . "\r\n" . 'Reply-To: noreply@noreply.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if (!strcmp($_GET["authcode"], $authcode)) { echo "Authentication successful! "; if (!$DEBUG) { foreach ($recipients as $recipient) { mail($recipient, $subject, $message, $headers); echo "Messages sent!"; } } } else { echo "Authentication failed!"; die(); }
Example of SMS alert
mbed Components
- 1 x uLCD-144-G2
- 4 x Parallax Pushbuttons
- 1 x Ethernet Magjack with Breakout Board
- 1 x 8 Ohm Speaker
- 1 x Shiftbrite RGB LED
- 1 x IR sensor with JST cable
uLCD Connections
mbed | uLCD |
---|---|
VU | 5V |
Gnd | Gnd |
P28 | RX |
P27 | TX |
P29 | Reset |
Pushbutton Connections
Pushbutton 1: P21
Pushbutton 2: P22
Pushbutton 3: P23
Pushbutton 4: P24
Ethernet Connections
mbed | MagJack |
---|---|
TD+ | P1 |
TD- | P2 |
RD+ | P7 |
RD- | P8 |
Speaker Connections
Speaker: P26
RGB LED Connections
mbed | ShiftBrite |
---|---|
Gnd | Gnd |
P11 | DI |
P15 | LI |
P16 | EI |
P13 | CI |
VU | V+ |
IR Sensor Connections
mbed | IR Sensor |
---|---|
Gnd | Gnd |
VU | Vcc |
Vo | P20 |
Source Code
Import programLab4_Two_Factor2
compilable code before testing
Future Features
- WiFi instead of Ethernet
- LED strip instead of single ShiftBrite LED
- 9-digit keypad instead of 4 pushbuttons
- 2 factor authentication for disabling alarm
Please log in to post comments.