PIR Home Automation

Introduction: PIR Home Automation

About: Electronics Engineer , Maker and innovator.

SENSZY(Version 1) - Home Automation using PIR

I'm sick and tired of pressing buttons to turn on lights and fan of my room, so I thought of making an automation circuit for my room, but I wanted no buttons to press even no screen to tap, no android interface, no IR remote, I wanted it to be completely autonomous system. So, I came up with this circuit which makes use of two PIR sensors and a ATTiny85. I wanted to use as minimum as possible hardware.

Features :

1. Turn ON/OFF lights and fan automatically when I enter in room or make an exit.

2. Turn OFF only the lights after I go to sleep, and turn them back ON when I wake up.

Want to know How I made it ?

Follow the instructable =================================>>>

Step 1: Things You Will Need to Make This Circuit !

Requirements :

- Arduino UNO R3

- ATTiny85 ( here I'm using a SMD package, I removed it from Digispark board, but I recommend PDIP IC).

- Breadboard.

- Jumper wires.

- 2 PIR sensors.

- Female and male headers.

- 12V adapter.

- LM7805, 10uF and 100uF capacitor ( for 5V regulation ).

- 10uF capacitor( for Arduino ).

- Soldering iron and solder wire.

- 2 meters ribbon cable ( you can use any cable available to you easily ).

- Perforated PCB.

- Piler and wire stripper.

- XBOX 360 game DVD cover ( for making mounts for PIR sensors )

- Electrical insulating tape

Lets get started with prototyping !

Step 2: Getting Started With Prototype !

Let us first connect the two PIR sensors to ATTiny85

Step down the 12V supply to 5V using LM7805( refer to image ) for power supply.

If you have 5V source use it instead.

Start by plugging ATTiny85 on the breadboard and make the connections as given below:

5V ======> Pin 8 of Attiny85

Gnd ======> Pin 4 of Attiny85

PIR 1 =====> Pin 6 of Attiny85

PIR 2 =====> Pin 2 of Attiny85

Vcc of both sensors ======> 5V power rail
Gnd of both sensors ======> Gnd rail

Refer the images for connections.

Next let us connect the 4 channel relay board=====>>

Step 3: Connecting the Relay Board

I am using a 4 channel relay board I bought from ebay, make sure your relay board have 5V relays not 12V.

We will be connecting the appliances to relays i.e., lights and fan.

To connect relay board to Attiny85 follow the below connections :

Relay board Vcc =====>> 5V

Relay board Gnd =====>> Gnd

Relay 1 on board =====>> Pin 7 of Attiny85

Relay 2 on board =====>> Pin 3 of Attiny85

Refer to image for

This is optional


Also connect a LED to circuit, for making a indicator for circuit startup( I have programmed the startup period for 60 seconds because PIR sensor takes few seconds to warm up to give accurate readings. )

LED positive terminal ====> Pin 5 of Attiny85

LED negative terminal =====> Gnd


I have just a fluorescent light and fan to control in my room, so I am making use of only two relays, with this circuit you can control maximum of 4 appliances.

Next we will set up Arduino IDE to use Arduino UNO as ISP to program Attiny85=======>

Step 4: Setting Up Arduino IDE

Now we need to program Attiny85 using Arduino IDE, for this we will make use of Arduino UNO as ISP. But before that we need to set up few things, follow the instructions below:

Step 1: Connect Arduino UNO to PC

Step 2: Open Arduino IDE and open the ArduinoISP example file (File -> Examples -> ArduinoISP) and upload it.

Step 3: Open File -> Preferences and in the Additional Boards Manager URLs give this url "https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json."

Step 4: After this is done open Tools -> Board -> Board Manager

After opening Board Manager scroll down the list where it says "attiny by Davis A. Mellis". Click on that and install it.

Step 5: Now back to Arduino IDE. Select ATtiny under Tools -> Board. Then
select ATtiny85 under Tools -> Processor. And select 8 MHz (internal) under Tools -> Clock.

Step 6: Then make sure Arduino as ISP is selected under Tools -> Programmer

Next we will connect Arduino UNO to Attiny85 to program it =============>>

Step 5: Programming Attiny85 With Arduino UNO

Now with all the things ready we will start programming the attiny85. Connect the arduino uno to attiny85 using breadboard as below.

Arduino Uno – ATtiny85

5V – Vcc

Gnd – Gnd

Pin 13 – Pin 2

Pin 12 – Pin 1

Pin 11 – Pin 0

Pin 10 – Reset

Temporarily, remove the sensors and relays from the pins of Attiny85, or the upload will encounter problems.

After you connect them like given above, make sure that you have selected Arduino as ISP from programmer menu.

Next download the code from below, open it and upload it.

After uploading the code, connect back all the pins of sensors and relays, remove arduino power source from prototype and power it up with 5V supply. Now prototype should be working well.

Next we will make the circuit on PCB and set up the plastic enclosure and make mounts for PIR sensors =======>>

Step 6: Making Final PCB

- Start by soldering IC socket on to board, I used SMD package so i made a kind of breakout for it and soldered it on the perforated pcb.

- then solder the 4 wires from ribbon wires to IC for connecting relay board and its power supply( image 3 ) terminate it with female headers, it will connect to the male headers of relay board.

- then solder led using two wires.( image 3 )

- connect 2 meter long cable for pir sensors as they need to be mounted.

- set up the plastic enclosure for housing the entire circuit and make holes into in for wires to come out.

- then make some mounts for pir sensors( refer to image 8 and 9 ) using plastic cover from xbox game.


- Mount PIR 1 near the room entrance and make sure its isolated from motion inside and outside the room, it need to detect motion in the entrance only.

- Mount PIR 2 in the room, pick a place where it can detect motion from anywhere in the room.

Next we will connect lights and fan to the relay board ==============>>


Step 7: Connecting Relays With Appliances

Relays have three terminals to connect with, Common, Normally open, Normally closed.

Normally Open will be closed when 5v is supplied to coil of relay, it will be triggered by MCU when motion will be detected.

Cut down the positive rail of you appliances and connect them to common(C) and normally open(NO) of the relay connectors.

Refer to images.

Warning: here you will deal with 220V, be careful. Don't touch the naked wire and also the back of relay board.

Step 8: Project Completed. Congratulations !

If you have followed the instructable, circuit must be working. Connect the circuit to 5V by pluging in the adapter to wall. Then led will glow for 60 seconds indicating that circuit is getting started, now move out of the room. After 60 seconds come back in the room and lights and fan will be now automated.

Plus the second pir sensor will be detecting motion inside the room, if you will sleep it will automatically turn off only lights after 10 minutes and when you will wake up, light will be turned on automatically.

Congratulations !

Thank you ! for reading my first instructable.

Follow me on instagram : @nishantnirala - I post my projects and ideas daily.

Add me on facebook : nishant.nirala5@gmail.com

Sensors Contest 2016

Participated in the
Sensors Contest 2016

Be the First to Share


    • Microcontroller Contest

      Microcontroller Contest
    • Automation Contest

      Automation Contest
    • Make it Glow Contest

      Make it Glow Contest



    3 years ago

    hi, why you additionally use attiny85 instead of atmega328... what is tha purpose


    3 years ago

    brother , someone will ask like why a take additional ATtiny85 ?? already in arduino uno having atmega328 .. so it is also do same functions then why u use attiny85 ... tell me quick


    4 years ago

    Very cool project! Thanks for sharing your first instructable, can't wait to see what you make next :)