How to Build a Low Cost DIY Smart Home Automation System with Arduino

Building your own smart home automation system can seem daunting, but it's actually quite achievable even on a budget by using an Arduino microcontroller. Here's a step-by-step guide to building your own low cost DIY smart home automation system.

Understanding the Components

Before we start building, let's first go over the main components we'll need for a basic Arduino smart home setup.

Arduino Microcontroller

The Arduino is the brain of your DIY smart home system. It's a small programmable microcontroller board that can be programmed to control electronic components and read data from various sensors.

The most popular boards are the Arduino Uno or Arduino Nano which are inexpensive but powerful options. I prefer the Nano for home automation projects as its small size makes it easy to incorporate into your final projects.

Relays

Relays are essentially remote controlled electronic switches. They allow the Arduino to turn things on and off, like lights, fans or appliances.

I recommend getting relay modules that have 4 or 8 relays on a board, which lets you control multiple devices while neatly packaging the relays together.

Sensors

Sensors give your Arduino eyes and ears. Simple sensors like motion detectors, door/window contacts, or temperature and humidity sensors allow the Arduino to monitor conditions in your home and trigger actions based on sensor data.

Useful sensors for home automation include:

Jumper wires

You'll need various jumper wires to make all the electrical connections between components. Get a pack with both male-to-male and male-to-female wires of differing lengths.

Breadboard

A breadboard allows you to prototype and test your circuit without soldering. You simply plug components into the breadboard and use jumper wires to connect everything.

While not mandatory, a breadboard makes prototyping much easier.

HC-05 Bluetooth Module (Optional)

An HC-05 Bluetooth module allows you to wirelessly control your Arduino smart home from your smartphone. This adds remote access and control options.

Hardware Assembly

Here's how to assemble the core hardware components:

1. Connect the Arduino

Plug the Arduino Nano or Uno into the breadboard. Use jumper wires to connect the 5V and GND pins to the power rails on the breadboard.

2. Connect the relays

Place the relay module on the breadboard and use jumper wires to connect the following pins:

I generally connect each relay IN pin to a separate Arduino I/O pin for individual control.

3. Connect sensors

Use jumper wires to connect any sensors you want to use to the Arduino's I/O pins. Refer to each sensor's documentation for specifics on how to wire them correctly.

Some sensors like DHT22 have dedicated Arduino libraries which make reading their data easy.

4. Connect Bluetooth module (optional)

To add Bluetooth, connect the HC-05 module to the Arduino using jumper wires:

Software Programming

Once the hardware is assembled, we need to program the Arduino to actually control everything. Here are the key steps:

1. Install Arduino IDE

Download and install the Arduino IDE on your computer. This allows you to write code and upload it to the Arduino.

2. Install required libraries

Install any required sensor libraries like DHT or DallasTemperature to allow reading sensor data.

3. Write your program

In the Arduino IDE, write your program to:

See example programs below for reference.

4. Upload to Arduino

Select your board type and COM port, then upload the program to the Arduino.

Sample Program Walkthrough

Here is an example basic program to control a light via Bluetooth based on a PIR motion sensor:

```c
//Initialize motionSensor at pin 2 and lightRelay at pin 4
int motionSensor = 2;
int lightRelay = 4;

//Initialize Bluetooth serial communication
SoftwareSerial bt(10, 11);

void setup() {

//Set motionSensor pin as INPUT
pinMode(motionSensor, INPUT);

//Set lightRelay pin as OUTPUT
pinMode(lightRelay, OUTPUT);

//Begin serial communcation
bt.begin(9600);

}

void loop(){

//Check if motion detected
if(digitalRead(motionSensor)==HIGH){

//Turn light on if motion    
digitalWrite(lightRelay, HIGH);

//Send confirmation over Bluetooth
bt.println("Light turned ON");

}
else
{

//Turn light off if no motion
digitalWrite(lightRelay, LOW);

//Send confirmation over Bluetooth
bt.println("Light turned OFF");

}

//Wait 2 seconds
delay(2000);

}
```

This gives you a basic automated light that turns on when motion is detected and off when no motion. The current status is also sent over Bluetooth so you can monitor it from your phone.

You can expand on this simple program to add more sensors, remotely control relays via Bluetooth, program scheduled actions like turning lights on at sunset etc. The possibilities are endless!

Enclosure and Installing

For a permanent installation, you will want to enclose your Arduino circuit in a protective housing rather than leaving it on a breadboard.

Some options are:

Sensors can be mounted using adhesive mounts or small screw mounts depending on the type of sensor.

Relays can be connected to lamps, appliances or lights via their screw terminals or spliced into existing wiring. Just make sure to shut off power at the breaker when splicing relay modules into existing electrical systems.

Conclusion

Building your own Arduino based smart home automation system is an achievable and fun DIY project. With just a cheap Arduino board, basic components like relays and sensors, and some simple software coding, you can construct a capable home automation system on a budget.

Start small with automating a few lights and expand your system over time. The modular nature of Arduino makes it easy to incrementally add new features whenever you want. Let me know in the comments if you have any other questions!