Introduction: Motion Controlled Outlet
Problem:
I had a problem with having a light switch in the wrong end of the corridor. I also didn't want to have a new switch installed because of the historical value of the building. Until now I have used a normal floor lamp but switching the lamp on and off all the time is bit frustrating. That's is why I thought of having the lamp motion controlled. There are few other projects like this but I thought of sharing my own version with you.
In my project I wanted to keep it simple but as versatile as I could. Therefore I decided to use Arduino in this project. I also wanted to have the system built so that it can be modified later to mach my needs in the future.
The device could also be used to trigger instead of relays various other things. The relays I used in this project are not suited for heavy load over 1 kW. Therefore if more power is needed should the relays be replaced with bigger ones that can handle bigger currents.
Solution:
I came up with a design that uses an Arduino and a passive infrared sensor (PIR) to detect movement. The sensor itself has a variable delay from 1 to 30 second but it wasn't enough for my purposes and that is why I included Arduino to have as much delay as I want. After being triggered the relays will stay on for short period of time that is set with a trimmer potentiometer. I also added a feature that makes the device work only in the dark because I don't want the lamp to be turned on in daytime.
Disclaimer:
This project includes working with mains and if you are not certain what you are doing please don't do it! I don't take any responsibility in any accident that might occur while building or using the presented project.
Safety:
This project includes working with mains so I also wanted to pay attention to safety. That is why I used two relays to switch the mains (both live L and neutral N). Switching only the other wire leaves the device potentially hazardous. With alternating current the polarity changes 50 to 60 times in a second so half of the time the controlled appliance would have live potential (230 V or 110 V) applied to it. Also the main switch must be double pole type. I used an aluminium enclosure for the project and that is why grounding the device isextremely important! In the worst case scenario that live voltage would be applied to the enclosure it would short out the circuit to the ground and blow the fuse. I also used shrink tubing as much as possible to protect the live contacts from being touched.
Parts needed:
Arduino (I used UNO to program the Atmega328-PU)
Relay module (I used this)
PIR-sensor (I used this, Adafruit)
Atmega328-PU (with Arduino boot loader)
28-pin socket
16 MHz crystal oscillator
7805 positive 5V regulator and heat sink
Rectifier diode bridge
6 V transformer (Anything will do from 6 to 25 V)
2x 22 pF ceramic capacitors
2x 10k ohm resistor
220 ohm resistor
LDR
LED ( I used red)
100 uF Electrolytic capacitor
10 uF electrolytic capacitor
4 and 3-pin Harwin connectors
Fuse holder and fuses (Depending on the relays. I used 2 A for max load of 460 W. The relays were rated for 5 A)
2 x AC sockets
Screw terminals
Mains switch (DPST)
Shrink tubing
22 AWG Hook-up wire
16 AWG wire for the live connections
Enclosure
Step 1: The Schematic
Parts needed:
Arduino (I used UNO to program the Atmega328-PU)
Relay module (I used this)
PIR-sensor (I used this, Adafruit)
Atmega328-PU (with Arduino boot loader)
28-pin socket
16 MHz crystal oscillator
7805 positive 5V regulator and heat sink
Rectifier diode bridge
6 V transformer (Anything will do from 6 to 25 V)
2x 22 pF ceramic capacitors
2x 10k ohm resistor
220 ohm resistor
LDR LED ( I used red)
100uF Electrolytic capacitor rated 50V
10 uF electrolytic capacitor rated 50V
4 and 3-pin Harwin connectors
Fuse holder and fuses (Depending on the relays. I used 2 A for max load of 460 W. The relays were rated for 5 A)
2x AC sockets
Screw terminals
Mains switch (DPST)
Shrink tubing
22 AWG Hook-up wire
16 AWG wire for the live connections
Enclosure
Step 2: Testing and Programming
First I tested the code and the circuit with Arduino and a breadboard. After that I uploaded the code to the Atmega328 microcontroller with Arduino and built the circuits to perfboards so that they could be easily modified if necessary. The LED in the Arduino module will turn on to indicate that the motion sensing is active when the lighting conditions have gone below the threshold that is set with the trimmer potentiometer.
Attachments
Step 3: Enclosure
I decided to put the project into a metal enclosure because I wanted to have robust case that would protect the insides. I used a Dremell to cut the holes for the PIR-sensor and the sockets. I also painted the enclosure with hammer paint to have a more vintage look.