Home Automation/Security Prototype

Written by: techguru

Picture of Home Automation/Security Prototype

I've been playing with micro-controllers for quite long and then I my friends asked me to take up this project and I was little bit nervous because working with individual home automation modules is relatively easier than to building an All-In-One Home Automation System which can be controlled by Android phone and it turned out to be really cool prototype and now I'm planning to implement it and amaze my friends.

This instructable will cover each and every step involved in making of this smart Automation/Security Prototype.

Step 1: The Big_Idea

Picture of The Big_Idea

The basic idea behind this project was to make a prototype of Home Automation/Security system using minimum hardware and maximum modules so as to cover many aspects of automation as possible. After this prototype is developed successfully and all testing done in various conditions, I can now implement it at home for safety and security purposes and ease my work which we all have deal with like switching 'ON' and 'OFF' lights every now and then. For this I'll be using AVR's family micro-controllers namely ATMega16/8 but most of you might be having Arduino as it makes project easier comparatively or even if you have any other micro-controller, You can just follow or go through this instructable and you'll have idea so as how to make this project for yourself.

I'll be compiling/stating various uses of different modules after discussing their working and implementation.

Step 2: Parts List

Picture of Parts Listgas.jpgir1.jpgxbhgiw1350351695996.jpgburner.jpgprxmty.jpgPDIP.jpg

Here's the list of parts and modules, and though it's a project that can be made according to requirements so you can just fetch the modules you require and the modules I used are :


# HC-SR 04

# MQ-2/3

# IR Sensor


# Proximity Sensor


  • ATMega16/8 prototype Board
  • Burner Kit
  • LED's
  • HC-05 (Heart of this project)
  • L293D module
  • BO-Motors


Basically this is all that was used. Apart from all this some resistors and Breadboard was used and connecting wires and for prototype some craft stuff like cardboard and chart papers were used.

Step 3: Distance Measurement (HC-SR 04)

Picture of Distance Measurement (HC-SR 04)IMG_1345.JPG20150414_202625.jpg

For HC-SR 04, I've used ATMega8 with following Pin-Out, You can just interface it and burn hex.

HC-SR 04 ATMeaga-8


Trig PC0

Echo PC1


Some Geeky Stuff :-

The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats or dolphins do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package. From 2cm to 400 cm or 1” to 13 feet. It operation is not affected by sunlight or black material like Sharp rangefinders are (although acoustically soft materials like cloth can be difficult to detect). It comes complete with ultrasonic transmitter and receiver module.

To start measurement, Trig of HC-SR04 must receive a pulse of high (5V) for at least 10us, this will initiate the sensor will transmit out 8 cycle of ultrasonic burst at 40kHz and wait for the reflected ultrasonic burst. When the sensor detected ultrasonic from receiver, it will set the Echo pin to high (5V) and delay for a period (width) which proportion to distance. To obtain the distance, measure the width (Ton) of Echo pin.

Time = Width of Echo pulse, in uS (micro second)

Distance in centimeters = Time / 58

Distance measurement can be used in many ways for example while trekking at night, for blind persons, automatic way finding bots and lot more.


Step 4: Interfacing Sensors (AVR-ADC)

Picture of Interfacing Sensors (AVR-ADC)

Most real world data is analog. Whether it be temperature, pressure, voltage, etc, their variation is always analog in nature. All this is simply analog data and we must process the data that we have received. But analog signal processing is quite inefficient in terms of accuracy, speed and desired output. Hence, we convert them to digital form using an Analog to Digital Converter (ADC). The AVR features inbuilt ADC in almost all its MCU. In ATMEGA16, PORTA contains the ADC pins. Now If you have more than one analog voltage source, more than one sensor, for instance, you can read all of them as long as the number of sources is fewer than the number of ADC pins you have on your microcontroller. With the Atmega16, there are 8 ADC pins. The only thing to keep in mind when programming the ADC to read multiple channels is that only one channel can be used in the conversion at a time.

In ATMega16, you just need to change MUX channel and assign values according to datasheet for selecting different ADC channel.

Here's how it's done :

ADMUX – ADC Multiplexer Selection Register

MUX4:0 – Analog Channel and Gain Selection Bits – There are 8 ADC channels (PA0…PA7).

Refer datasheet for more info.

Now since analog sensors will give analog voltages so according to situations you should know what is the output of sensor so as you can program and carry out respective operations accordingly.

To do that, just check the output voltage of sensor using multi-meter and use formula to convert it to adc value;


And you'll be done with sensors now, though sensors requires lot of testing and I did lot of testing so as to ensure that outcome after programming according to values I noted using multi-meter are right and accurate.

For more info regarding ADC programming, refer this link.

Step 5: AVR-HC 05 Connections

Picture of AVR-HC 05 Connections

Description about HC-05 : HC-05 is a class-2 bluetooth module with Serial Port Profile , which can configure as either Master or slave. You can use it simply for a serial port replacement to establish connection between MCU, PC to your embedded project and etc.

Now our MCU runs on 5v DC voltage whereas HC-05 requires 3.3v Dc so you need to make a level shifter which is pretty easy or buy module which supports 5v so it will be less troublesome.

In ATMega16, we have PD0/1 as Rx and Tx pins.

I just required PD0 as I was using my android device so I just needed to send data and not receive.

Always remember that Txd pin of HC 05 goes to Rxd pin of MCU and vice-versa.


Now since are controlling our prototype with bluetooth so we need to program and know a bit about USART also.

USART stands for Universal Synchronous AsynchronousReceiver/Transmitter. This is of the synchronous type, i.e. the data bits are synchronized with the clock pulses.

Steps to set-up USART of AVR :-

+> The first step is to set the baud rate in both, the master and the slave.

+> The baud rate has to be the same for both – master and slave.

+> Set the number of data bits, which needs to be sent.

+> Save the received data so that the new received data can be overwritten onto it.

+> Then enable the transmitter/receiver according to the desired usage.

USART Pin Configuration :-
RxD: USART Receiver Pin ( ATMega16 Pin 14) {HC 05 connected at this pin }

TxD: USART Transmit Pin (ATMega16 Pin 15)

Now since the baud rate of android device's bluetooth is 9600 so same has to be set for ATMega 16.

It is done by using USART Baud Rate Register (UBRR).

Refer this tutorial for more info regarding USART.

Step 7: Android Program

Picture of Android ProgramScreenshot_2015-04-05-16-12-13.png

If you are beginner to android and don't know android programming, Cool, Don't worry MIT App Inventor is what all you need.

I'm providing you .apk file of app which I made.

It basically sends Input to MCU to switch to module you want to activate.

I'm also providing .aia so that you can check the block and designer part in MIT app inventor and customize at your will.

App is pretty cool and I was pretty amazed, Thanks to MIT App developer.



Step 8: Connections and Interfacing

Picture of Connections and InterfacingIMG_1338.JPGIMG_1335.JPGIMG_1344.JPGIMG_1349.JPGIMG_1330.JPGIMG_1336.JPGIMG_1337.JPGIMG_1339.JPG20150408_180316_Richtone(HDR).jpg

After all the programming part, it was time to test each and every module and above are the pics of how I managed connecting sensors to MCU, I provided ATMega8 with battery power supply and I was out of batteries so used 12v 1A adapter for ATMega16.





Step 9: Uses of Various Sensors

Here are the uses of different sensors that are generally used for home automation/security purposes.

Gas Sensor(MQ2) module is useful for gas leakage detecting(in home and industry). It can detect LPG, i-butane, methane, alcohol, Hydrogen, smoke and so on. Based on its fast response time. Measurements can be taken as soon as possible. Also the sensitivity can be adjusted by the potentiometer.

MQ3 Sensor is suitable for detecting alcohol concentration on your breath, just like your common breathalyzer. It has a high sensitivity and fast response time. It can be used at home or clubs as it helps avoiding drink and drive cases :p

LDR’s have low cost and simple structure. They are often used as light sensors. They are used when there is a need to detect absences or presences of light like in a camera light meter. Used in street lamps, alarm clock, burglar alarm circuits, light intensity meters, for counting the packages moving on a conveyor belt, etc.

IR Sensor can be employed for many reasons and burglar alarm circuits/Home security Systems is one of many to name.






Step 10: Preparing Prototype

Picture of Preparing Prototype20150408_180048_Richtone(HDR).jpg20150408_175917_Richtone(HDR).jpg20150412_114800_Richtone(HDR).jpgIMG_1332.JPGIMG_1331.JPGIMG_1342.JPGIMG_1351.JPGIMG_1333.JPGIMG_1348.JPGIMG_1352.JPG20150414_145336.jpg20150414_154914.jpg20150414_154920.jpg20150414_172308.jpg20150414_180055.jpg20150414_175214.jpg55339a63dbf3ecad2d000016.jpeg20150414_202426.jpg20150414_202555.jpg20150414_213318.jpg20150414_213312.jpg

For preparation of Prototype, I basically used cardboard, Chart paper, and lot of double sided tape.

Pics above will give you idea about how it was prepared.

Starting from outlining to cutting and pasting and making elegant boundary with black tape again.





Step 11: Testing and Final Videos

Picture of Testing and Final Videos20150414_212016.jpg20150414_202720.jpg20150414_212005.jpg20150414_202728.jpg20150405_160911.jpg20150405_160936.jpg20150405_161011.jpg

Hope you liked my Project.










Leave a Reply