Lights On!

Hi there!

It sometimes happens that we build something out of necessity, to help us with little day-to-day tasks, and this is the case for today’s project.

The boiler’s room in my basement is a very cramped place that I need to access frequently because I keep in there a freezer for groceries. It turns out that I often have my hands full when I come back from taking something from the freezer, and it is difficult to reach for the light switch.

To obviate to this problem, I decided to build an automatic light switch, so I don’t have to maneuver it manually anymore. And, since I was at that, I decided to make one that not just turns off when I leave the room, but also turns on the light automatically when I enter the room.


The core of this device, technically called an Occupancy Sensor, is a PIR, or Passive Infrared sensor. I have a version of it called HC-SR501 that puts together a Pyroelectric Infrared Detector, or PID, with a bunch of other electronic components that make the sensor useable with very few external components. The PID is concealed underneath that white little dome, which is nothing more than a Fresnel lens that concentrates the light on the actual sensor, thus increasing its sensitivity.


The PID used in this device is called LHI 778, and is capable of detecting infrared emissions over a background noise of up to 85 degrees Celsius. You can see from its data sheet that it is like a small metallic cylinder with 4 pins coming out of it. This PID actually contains two infrared sensors connected in series, to increase its sensitivity.

This one is the schematic I made to use the PIR motion detector. The Detector is connected through the pin header J1 on the left. The header provides the power supply for the detector on pins 1 and 3, and captures the output signal on pin 2.

The signal from the detector goes to the base of transistor Q1 which pilots a relay that is used to control the lights of the room where the device is located.

The 5V power supply for the transistor and the relay comes from an old USB charger, so I didn’t have to build a power supply just for this application. LED1 and R1 provide a visual indication that tells us when the gadget is turned on.

The actual power supply for the whole thing comes directly from a 120V socket, goes through a 1A fuse, and through a power switch.

When the switch is set to on, both the USB charger and the common terminal of the relay receive the 120V. Power socket J3 receives the 120V only when the switch is on and, simultaneously, the PIR detects the presence of a person.

The following archive contains all the files you will need if you decided to build this device for yourself, and more.

You can also watch this video for further details on the construction of this device.

Important note: this device involves the use of potentially deadly voltages and you should not try to replicate it if you have no experience with high voltages. Build it at your own risk.

Experimentation Boards

How to experiment with electronic components to try new things and test your designs

It comes the time where you want to do some experiments to learn how a specific circuit works or to test a new circuit that you are designing.

Fundamentally, there are two options for you:

  1. Use a perforated board where you can solder the components to build the circuit you want to test.
  2. Use a solder-less breadboard, which allows you to build the circuit you need and, later, dismantle it without any damage to the components you used.

There is actually a third possibility, which is to use a PCB, or Printed Circuit Board. However, I will not consider that right now. PCB are normally used in later stage of development, when you are ready to put your design in a more definitive form. Using a PCB board at the early stages of design is not convenient, due to the cost and time needed just to produce the board itself over and over again, until you are satisfied with your design.

Personally, when I am in the first stages of a new design, and I need to try  a new piece of electronic circuit, I prefer to use a solder-less breadboard, which allows me to modify the circuit at will while I test different versions of it.

02_DSC00020

Once I am satisfied with the design and I need to build my first real prototype, I then use a perforated board. In this case I lay down all the components on one side of it, normally the one with no metallic pads, and then I solder the components on the other side, where the metallic pads are located. At the same time I start running the cables from the lead of one component to another, to make all the electric connections between components.

02_DSC00027

If what I need is just one circuit for personal purposes, then I might as well end it right there, leaving the circuit on the perforated board. But if I needed to build several of those circuits, then I start thinking of manufacturing a PCB. But this is a subject for another time.

Since I work a lot with Arduino and Raspberry Pi boards, I have also created my own version of experimentation board, which is basically a piece of cardboard that I covered with blue tape, with  a bunch of stuff glued to it: a couple of breadboards, an Arduino Uno, a Raspberry Pi, and a small LCD display. I also added a few little trays to temporarily place some components needed to build the circuit, or to hold bigger components that are part of the project and cannot fit on the breadboards.

02_DSC00023

This configuration allows me to build my experimentation circuits in a neat way, without having too many things lying around on the workbench. It is very easy to move around the built circuit when it is done on such a custom board.

(Watch the video on YouTube: https://www.youtube.com/watch?v=Wv7kVVZvULA&t=13s)