Making your own smart home security system with Arduino is an achievable weekend project that can be done on a budget under $50. With just a few components, you can build a basic system to detect motion, monitor doors and windows, and get alerts to your phone.

What You Will Need

To build your budget DIY smart home security system, you will need:


The Arduino is an open-source microcontroller board that serves as the brains of the system. The Arduino Uno or Arduino Nano will work well and cost under $10.


Sensors detect activity and send signals to the Arduino. You will need:

Try to get a kit with assorted sensors for cost savings.

WiFi Module

A WiFi module like the ESP8266 allows the Arduino to connect to WiFi and send notifications over the internet. This component costs around $5.


You may already have some of these parts on hand.

Prototype on a Breadboard First

Before permanently assembling your Arduino security system, first prototype the circuit on a breadboard. This allows you to test components and connections more easily.

Connect Motion Sensor

The PIR motion sensor has three pins - power, ground, and data. Connect the power pin to 5V on the Arduino, ground to Arduino ground, and data to a digital I/O pin like D8.

Connect Magnetic Switches

Magnetic contact switches also have three pins. Connect power to 5V, ground to ground, and data pins to different digital I/O (e.g. D2 for front door).

Connect Other Sensors

Connect the smoke sensor and any other sensors similarly, using different digital pins. The data pins will attach to interrupts on the Arduino.

Connect WiFi Module

The ESP8266 WiFi module connects to power, ground, and via serial pins to the Arduino RX/TX. Ensure the baud rate matches on both boards.

Load Code

With all components wired up, it's time to program the Arduino with code to handle reading the sensors and sending alerts. This is covered next.

Writing the Arduino Code

The Arduino code will need to initialize the components, read data from the sensors, connect to WiFi, and send notifications.

Include Required Libraries

First install and include libraries like <ESP8266WiFi.h> and <PubSubClient.h> to provide WiFi and MQTT functionality.





Initialize Pins and Variables

Next initialize all the pins, WiFi credentials, MQTT broker details, and global variables.

const char ssid = "yourNetworkName";
const char
password = "yourNetworkPassword";

const char* mqtt_server = ""; //broker IP

define motionSensorPin 8

define doorSensorPin 2


int motionState = 0;
int doorState = 0;

Setup Function

In the setup() function, initialize serial, WiFi, and MQTT connections. Also initialize motion and door sensors as inputs with internal pull-ups enabled.

void setup() {


WiFi.begin(ssid, password);

client.setServer(mqtt_server, 1883);

pinMode(motionSensorPin, INPUT_PULLUP);
pinMode(doorSensorPin, INPUT_PULLUP);


Main Loop

Continuously check the sensors for activity and send alerts as needed in the loop() function:

void loop() {

motionState = digitalRead(motionSensorPin);

if(motionState == HIGH) {
//send alert
client.publish("home/alarm", "Motion detected!");

// check other sensors

client.loop(); //MQTT client loop


Assembling the Circuit

With the code tested on the breadboard, it's time to assemble the circuit permanently on a protoboard or PCB.

Mount Components

First mount the Arduino, WiFi module, smoke detector, and other components to the board or enclosure using screws/tape.

Connect Jumper Wires

Then solder jumper wires to connect the devices according to your breadboard diagram. Optional: label wires with masking tape.

Power Supply

Provide a 9V battery pack with connector wires to power the Arduino and components. Use a regulator to step down to 5V.

Door/Window Sensors

Mount magnetic contact switches on doors, windows, garage door, etc using adhesive or screws. Run wires back to the main board.

Motion Sensor

Place the PIR motion sensor in a central location in a room. Adjust sensitivity and delay as needed.

Smoke Detector

Mount the smoke detector high on a wall or ceiling per manufacturer guidelines. Connect to Arduino.

WiFi Antenna

Ensure the WiFi module's antenna is positioned upright and has good reception.

Configuring Home Automation Software

To receive alerts from the Arduino security system, home automation software like Home Assistant is recommended.

Install Home Assistant

Home Assistant provides mobile push notifications, voice assistants, web dashboards, automation rules and more. Install it on a Raspberry Pi, local server, or sign up for hosted cloud access.

Enable MQTT Integration

In Home Assistant, enable the MQTT integration and point it to your MQTT broker (probably your WiFi module IP address on the local network).

Monitor Topics

Subscribe to MQTT topics like home/alarm in Home Assistant to receive messages published from the Arduino.

Create Automations

Set up automations like "When motion is detected, send me a push notification." This is configured graphically in the Home Assistant UI.

Improving the Security System

Here are some ideas for enhancing your budget Arduino security system over time:

By following this guide, you should be able to create an affordable starter DIY security system with Arduino and sensors to protect your home. As your needs grow, the system can be expanded and connected to home automation platforms. Let me know if you have any other questions!