Instructables

"Smart Shield" - Portable alarm system using Arduino

Picture of
PIR Sensor is connected to the arduino card. When a motion is being detected, an alarm sound and flashing LEDs will start to act. The times of the motion detections are saved, and can be viewed later on a small LCD screen. The data (motion detections) is sent via bluetooth and can be viewed on a smartphone by a designated app for android.
 
Remove these adsRemove these ads by Signing Up

Step 1: List of components

Picture of List of components
1.jpg
 
2. Motion detector (PIR sensor):
 
3. LCD screen (for showing the number of interrupts and their times of occurrences):
 
4. Small Speaker / piezo speaker.
 
5. LED / Flashing LEDs.
 
6. Push-button + 10k resistor.
 
7. Network module (serial communication):
PC connection: mini-USB to USB cable.
Bluetooth module (wireless):
 
JY-MCU - Specifications:
Dimensions: 4.4 cm x 1.6 cm x 0.7 cm (1.73 in x 0.63 in x 0.28 in)
Weight: 7g (0.25 oz)
Range: ~10 m (~33 ft)
Supply voltage: 3.6-6V
BT-Name: linvor
BT-Pin: 1234
BT-Baudrate: 9600bps (standard)
 
8. Wiring components: solderless breadboard, board, wires, connectors, headers.
 
9. Power input: 9V battery + battery case + connector + switch / external adaptor for arduino.
 
10.  A box (for containing all above, in a neat pack).
 
Software (the version I used mentioned in brackets, but a newer version for any software may work too):
 
1. Arduino Software (Ver. 1.0.1): http://arduino.cc/en/Main/Software
 
2. PC – Processing (Ver. 2.0b6), for testing purposes: http://www.processing.org/
 
3. Terminal - Tera Term (Ver. 4.75), for testing purposes: http://logmett.com/index.php?/download/tera-term-476-freeware.html
 
4. Android app "Smart Shield" (Android Developer Tools, Build: v21.0.0-531062), for developing in android (for anyone who wants to understand the code and to improve the app): http://developer.android.com/index.html
 

Step 2: Testing 1 - Building a simple circuit with the arduino, motion detector and LED indicator

Picture of Testing 1 - Building a simple circuit with the arduino, motion detector and LED indicator
The PIR Sensor is connected to the arduino card. The LED is turned on by a motion detection for 15 seconds.

Instructions:
http://www.instructables.com/id/Arduino-Basics-PIR-Sensor/
 

Step 3: Testing 2 - Adding a speaker and buttons to the simple circuit

Picture of Testing 2 - Adding a speaker and buttons to the simple circuit
I connected a speaker and a LED to the arduino and the PIR sensor.
The speaker makes an alarm sound that goes on and off and the LED turns on and off repeatedly.
 
Instructions:
 
crisnav093 days ago

good day ! hhmm I just want to ask , what if i would like to use a 9 volts charger as power source that is directly connected to the arduino power source. Do I still need to use rocker switch and push button switch? .. and oh by the way, I will no longer be using a 9 volts battery. Thank you.

BIGDOG12347 months ago

How do you add the app to your phone.

EranP (author)  BIGDOG12347 months ago

Download the Smart Shield.zip in step 10 and unzip the apk file in your pc.

Use a USB cable to transfer the apk file to your android smartphone (no iOS or other moblie OS yet, sorry...).

On the smartphone, go to Settings, scroll down to Security, and select Unknown sources. Selecting this option will allow you to install apps outside of the Google Play store.

Install the apk file.

For more information on "How to install apps outside of Google Play" follow the link:

http://howto.cnet.com/8301-11310_39-57602654-285/how-to-install-apps-outside-of-google-play/

BIGDOG12348 months ago
Now when I verified the code I got this:
Smart_Shield.ino: In function 'void setup()':
Smart_Shield:85: error: 'Serial1' was not declared in this scope
Smart_Shield.ino: In function 'void loop()':
Smart_Shield:135: error: 'Serial1' was not declared in this scope
Smart_Shield:165: error: 'Serial1' was not declared in this scope
Smart_Shield:188: error: 'Serial1' was not declared in this scope

What do I do.
EranP (author)  BIGDOG12348 months ago
It seems you have a serial problem.

What kind of board do you have?

The Arduino Leonardo board uses Serial1 to communicate via TTL (5V) serial on pins 0 (RX) and 1 (TX). Serial is reserved for USB CDC communication

All Arduino boards have at least one serial port (also known as a UART or USART): Serial. It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB. Thus, if you use these functions, you cannot also use pins 0 and 1 for digital input or output.

You can use the Arduino environment's built-in serial monitor to communicate with an Arduino board. Click the serial monitor button in the toolbar and select the same baud rate used in the call to begin().

For more information, refer to:
http://arduino.cc/en/reference/serial

Good Luck!
BIGDOG12348 months ago
I can not find StopWatch.h file.
EranP (author)  BIGDOG12348 months ago
Download the files (the rar files: StopWatch.rar, LiquidCrystal.rar) from step 9 and unrar them to your 'libraries' folder in the arduino files.
BIGDOG1234 EranP8 months ago
It did not work.
How do you unrar them.
EranP (author)  BIGDOG12348 months ago
To use this library, make a folder in your SKETCHBOOKPATH\libaries with the name StopWatch and put the .h and .cpp there. Close all your IDE's and then it is ready to use.

For further information, go to the following link:

http://playground.arduino.cc/Code/StopWatchClass
BIGDOG12348 months ago
When I verified the code I got this:
Smart_Shield:29: error: 'StopWatch' does not name a type
Smart_Shield:30: error: 'StopWatch' does not name a type
Smart_Shield:31: error: 'StopWatch' does not name a type
Smart_Shield:32: error: 'StopWatch' does not name a type
Smart_Shield:33: error: 'StopWatch' does not name a type
Smart_Shield:34: error: 'StopWatch' does not name a type
Smart_Shield.ino: In function 'void setup()':
Smart_Shield:83: error: 'Serial1' was not declared in this scope
Smart_Shield:85: error: 'sec' was not declared in this scope
Smart_Shield.ino: In function 'void loop()':
Smart_Shield:133: error: 'Serial1' was not declared in this scope
Smart_Shield:163: error: 'Serial1' was not declared in this scope
Smart_Shield:166: error: 'sec1' was not declared in this scope
Smart_Shield:167: error: 'sec2' was not declared in this scope
Smart_Shield:168: error: 'sec3' was not declared in this scope
Smart_Shield:169: error: 'sec4' was not declared in this scope
Smart_Shield:170: error: 'sec5' was not declared in this scope
Smart_Shield:186: error: 'Serial1' was not declared in this scope
Smart_Shield:196: error: 'sec' was not declared in this scope
Smart_Shield:211: error: 'sec' was not declared in this scope
Smart_Shield:214: error: 'sec' was not declared in this scope
Smart_Shield.ino: In function 'void KeypadPressed(int)':
Smart_Shield:321: error: 'sec' was not declared in this scope
Smart_Shield:351: error: 'sec1' was not declared in this scope
Smart_Shield:352: error: 'sec2' was not declared in this scope
Smart_Shield:353: error: 'sec3' was not declared in this scope
Smart_Shield:354: error: 'sec4' was not declared in this scope
Smart_Shield:355: error: 'sec5' was not declared in this scope
Smart_Shield:381: error: 'sec' was not declared in this scope
Smart_Shield:412: error: 'sec1' was not declared in this scope
Smart_Shield:413: error: 'sec2' was not declared in this scope
Smart_Shield:414: error: 'sec3' was not declared in this scope
Smart_Shield:415: error: 'sec4' was not declared in this scope
Smart_Shield:416: error: 'sec5' was not declared in this scope
Smart_Shield:442: error: 'sec' was not declared in this scope
Smart_Shield:459: error: 'sec' was not declared in this scope
Smart_Shield:485: error: 'sec' was not declared in this scope

What do I do.
EranP (author)  BIGDOG12348 months ago
Hi BIGDOG1234,

It seems there are some library files missing, such as StopWatch.h file.
Download the libraries from step 9 (Unzip them to your 'libraries' folder in the arduino files).

For more information on these libraries, check out the following links:

http://playground.arduino.cc/Code/StopWatchClass

http://arduino.cc/en/Reference/LiquidCrystal

For the serial1 problem, check that you have the right board (I've used the Arduino Leonardo board). Choose the board on the arduino software: Tools -> Board -> Arduino Leonardo (In my case).

For other boards, see more information regarding the serial1 connection (to avoid compatibility issues): http://arduino.cc/en/reference/serial
BIGDOG12348 months ago
Could you post the code you use on your "Smart Shield" - Portable alarm system in one file.
EranP (author)  BIGDOG12348 months ago
Hi BIGDOG1234,

The Code for the arduino is in the first zip file (Smart_Shield.zip, 3KB).

The code for the app is in the second zip file (Smart Shield.zip, 853 KB).

The other 3 rar files containing the source code of the app. I've divided the source code to 3 smaller files in order to upload it successfully to the page (I've encountered some problems involving uploading large files).
sartikahusain9 months ago
pliss the tutorial with arduino uno....pleaseee
EranP (author)  sartikahusain9 months ago
Hi sartikahusain,

There are some differences between the two arduino cards: Leonardo & Uno, Mainly on the USB and serial communication.

The Arduino Leonardo differ from Arduino Uno in that it uses a single microcontroller to both run your sketches and for USB communication with the computer. The Arduino Uno uses separate microcontrollers for these two functions, meaning that the USB connection to the computer remains established regardless of the state of the main microcontroller.

you can read more on the differences by clicking on the link:
http://arduino.cc/en/Guide/ArduinoLeonardoMicro?from=Guide.ArduinoLeonardo#toc1

I've used the Leonardo card because it is cheaper and Leonardo is my favorite ninja turtle. I've not tried to build the alarm with Uno card, but I can't see why you can't try and build it with the Uno card, with minor adaptations and modifications.

The big change will be in the arduino code:
Choose Tools > Board > Arduino Uno.
In the arduino software code, before uploading it to the Arduino Uno, change all the serial1 lines to serial and erase all the duplicated lines (2 serial lines, one after another).

I can't see any reason why it won't work and when I'll get an arduino Uno card I'll start to experiment on it and add it to this tutorial.
sk8amazing1 year ago
it has problem with serial1
EranP (author)  sk8amazing1 year ago
Hi sk8amazing,

To verify the code successfully do the following on the Arduino software:

Tools -> Board -> Arduino Leonardo.

Note: Arduino Leonardo is the board which I worked with.

For more information with serial on other boards:
http://arduino.cc/en/Reference/Serial