In this project, we will make a DIY Arduino Home Security System using an Arduino Mega and ROHM’s Sensor Evaluation Kit. The system uses a passive infrared sensor (PIR) sensor to detect any suspicious movement and ROHM’s Temperature Sensor (BD1020HFV) and Barometric Pressure Sensor (BM1383GLV) to detect heat. It will be connected to the internet using Arduino WiFi Shield to communicate with Cayenne API.
When somebody breaks into your place and the motions are detected, the system will trigger a buzzer and send email notifications to you through Cayenne. You will also get notified when the heat that’s higher than the preset temperature is detected. This Home Security Systems can be monitored and controlled 24/7 from the Cayenne website or via the Cayenne App on your smartphone.
A guide to how to setup the sensor shield and connect to Arduino was covered in the previous article. If you haven’t already, please refer back to ROHM Sensor Evaluation Kit Overview.
Figure 2. Acrylic casing for Arduino Mega
Let’s start by assembling the Arduino acrylic casing. Before putting the closure, we need to solder 2 wires (red and black) into Arduino VIN (12V); these wires will be used to power up remote control which requires 12V.
After assembling the casing, you can place the Mega in it. Use screws to attach the Mega to the acrylic base.
Drill holes on acrylic board to attach Arduino Mega and Grove Wrapper/Case. You will have to measure the dimensions of the modules and mark spots on the surface to drill holes. You can see the organization of my board below (Figure 15). You can rearrange the modules on the board to suit your preference. Use double tape to attach breadboard and remote control.
Next, connect the two black and red wires we just soldered from Arduino to the remote control unit. Note: Be careful with the terminal sign (+ and -).
Connect two male-male connector wires to one of the relay channels from the remote control unit. We’ll be using Channel D as shown in Figure 17.
Now place two resistors (100 Ohm and 10K Ohm) and three male-male wires onto the breadboard (see Figure 18). These resistors will be used as pull-up and pull-down resistors to send a signal from the remote control to Arduino (through Digital pin 41).
When we press remote control transmitter, the relay in remote control’s receiver will be toggled on or off. If the relay is in “ON” position, a 5V from relay will make Arduino pin 41 triggered into HIGH.
Note: The purple cable is for the relay and will be connected to 5V when it is “ON”. The gray cable will be connected to Arduino pin 41, and the black cable to Arduino GND pin.
Now, let’s place PIR sensor, Buzzer, Green LED, Blue LED and Red LED into Grove Wrapper/Case that are already screwed into the acrylic base board.
Let’s place the WiFi Shield on top of Arduino Mega. We have to make sure the pins are aligned correctly.
Next, we need to stack up ROHM’s Sensor Shield on top of the Wifi Shield we just installed. Again, we have to make sure the pins are aligned correctly. Then, we’ll connect the ROHM’s Temperature Sensor (BD1020HFV) to Analog 2 header and ROHM’s Barometric Pressure Sensor (BM138GLV) to I2C header on ROHM’s Sensor Shield (see Figure 21).
The Barometric Pressure Sensor (BM138GLV) works with either 1.8V or 3V, and the Temperature sensor with 3V or 5V. So we must set the voltage to 3V by putting the jumper into 3V (see Figure 21).
For more information about ROHM sensors, please refer back to ROHM Sensor Evaluation Kit Overview!
For one last time, we need to stack Grove Base Shield on top of the ROHM Sensor Shield. No more stacking after this, I promise! Always make sure the pins are aligned correctly. Now is a good time to triple check that everything we’ve stacked so far is aligned as it’s supposed to be.
Now the stacking is done, let’s connect the black cable from the breadboard to Arduino GND pin. We’ll then connect the white cable from the relay to Arduino pin 5V and gray cable from the breadboard to Arduino pin 41.
Now connect PIR sensor, buzzer, and LEDs to Arduino. Use Grove Universal 4 pin cables with one connector to the sensor and the other connector to Grove Base Shield. Pin numbers are already marked on Grove Base Shield so it should be easy to follow. Use the following table for reference:
|Connection From||To Arduino|
|PIR Motion Sensor||Arduino Pin 2 (Digital)|
|Blue LED||Arduino Pin 4 (Digital)|
|Green LED||Arduino Pin 6 (Digital)|
|Red LED||Arduino Pin 8 (Digital)|
|Buzzer||Arduino Pin 5 (Digital)|
|Remote Control||Arduino Pin 41 (Digital)|
The assigned pin numbers should be consistent throughout; they will be coded as is in our program:
#define PIR_MOTION_SENSOR 2 // Use pin 2 to receive the signal from the module
#define LED1 4 // Blue Led for motion detected
#define LED2 6 // Green Led for triggered alarm
#define LED3 8 // Red Led if motion and trigger switch are on
#define buzzer 5 // Buzzer
#define remote 41 // Remote Control
We’re done with hardware installation! This concludes Part 1 of our DIY Arduino Home Security System. In Part 2, we’ll write an offline program to test the system we just built and also connect to the Internet to allow wireless control using Cayenne API. We’ll walk you through the process of creating myDevices Cayenne and establishing a connection (the system to your Cayenne account) so you can wirelessly control the security system even when you’re not home. Stay tuned!