Introduction

Building a motion sensor alarm system with Arduino is an easy weekend project that can add security and convenience to your home or office. The alarm system will detect motion using a passive infrared (PIR) sensor and send you email alerts so you can respond promptly.

In this comprehensive guide, I will walk you through every step of constructing the alarm from start to finish. I'll cover:

What You Will Need

How It Works

Setting Up the Electronics

Writing the Arduino Sketch

Completing and Installing the Alarm

By the end, you will have a fully functioning motion alarm that notifies you whenever it detects movement. Let's get started!

What You Will Need

The following components are required to build the Arduino motion alarm:

Arduino Board

The brains of the alarm is an Arduino microcontroller board. The standard Arduino Uno will work well. The Arduino processes input from the PIR sensor and controls the outputs.

Arduino Uno Board

PIR Motion Sensor

A passive infrared or PIR motion sensor detects movement and triggers the alarm. It consists of an infrared sensitive element that detects temperature changes caused by motion.

PIR Motion Sensor

PIR Motion Sensor

The sensor has three pins - power, ground, and signal. When it detects movement, the signal pin outputs a high voltage.

LCD Display

A liquid crystal display (LCD) screen will show status messages like "System Armed" or "Motion Detected." A basic 16x2 LCD display with an I2C interface works well.

LCD Display

16x2 LCD Display

The I2C interface only needs 4 wires to connect to Arduino.

Buzzer

An active buzzer will sound an audible alarm when motion is detected. Connect the positive and negative pins to Arduino.

Buzzer

Active Buzzer

WiFi Module

To send email alerts, you need a WiFi module like the ESP8266. It will connect to your WiFi network and handle emails.

ESP8266 WiFi Module

ESP8266 WiFi Module

Jumper Wires and Breadboard

Use jumper wires to make all the connections between components. A breadboard provides a convenient way to prototype.

Jumper Wires

Jumper Wires and Breadboard

9V Battery and Clip

An external 9V battery and clip will power the Arduino and other components. This provides portable operation.

9V Battery Clip

9V Battery and Clip

How the Motion Alarm Works

Here is an overview of how the parts work together:

Setting Up the Electronics

With all the components ready, it's time to assemble the motion alarm on a breadboard and connect everything to the Arduino.

Breadboard Layout

Here is an example layout showing where each component goes:

Breadboard

Sample Breadboard Layout

Connecting Components

Next, use jumper wires to make the connections between all the electronics:

PIR Sensor

LCD Screen

Buzzer

WiFi Module

The Arduino, PIR sensor, LCD, and buzzer will be powered from the 9V battery through the Vin pin.

Now all the components are wired up and ready to be programmed!

Writing the Arduino Sketch

The Arduino software runs code called sketches to operate the motion alarm. The sketch will:

We need to include some libraries:

```c

include // LCD library

include // WiFi module library

```

In the setup, we initialize the LCD and buzzer pin:

```c
LiquidCrystal_I2C lcd(0x27, 16, 2); // LCD address, columns and rows

pinMode(buzzer, OUTPUT);
```

The main loop will continuously check the PIR sensor for motion detection:

```c
void loop() {

if (digitalRead(pirPin) == HIGH) {

// Motion detected!

digitalWrite(buzzer, HIGH); // Sound alarm
sendEmailAlert(); // Send email 
lcd.setCursor(0,0);
lcd.print("Motion Detected!"); // Print LCD alert

}
}
```

If motion is detected, it will trigger the buzzer, LCD, and email alert.

The sendEmailAlert() function uses the WiFi module to send an email:

```c
void sendEmailAlert() {

// Connect to WiFi
// Set up SMTP server credentials
// Send email message

lcd.setCursor(0,1);
lcd.print("Email Alert Sent!");
}
```

This Arduino sketch completes the programming of the motion alarm.

Completing and Installing the Alarm

After all the electronics are assembled and programmed, there are just a few final steps:

Now you have a DIY Arduino motion alarm system that will notify you through sound, text and email whenever it detects movement!

Some ways this can be used:

The possibilities are endless for enhancing your projects with motion sensing capabilities.

In summary, the key steps to build the Arduino motion alarm are:

With just a bit of effort, you can construct a fully-featured motion alarm system with email notifications using Arduino!