Skip to content

Home automation: Light that turns on when somebody is standing still in front of the mirror

License

Notifications You must be signed in to change notification settings

iver56/auto-light

Repository files navigation

How-to

What

Image

I've got these led lights beside the mirror in my house, and I want them to turn on automatically when somebody is standing still in front of the mirror. The led strips use 12 V and the current is around 160 mA. Let's create a relay driver that can turn on and off the lights using a Raspberry Pi model B+. The lights will still use their original power source, which is a 12 V DC adapter.

Circuit

Let's get the needed components to create something that looks like this: Circuit

GPIO pins

Raspberry Pi has a set of handy GPIO pins which we can use to interface with that circuit. Pin 7 can be used for for saturating the transistor and pin 9 is ground. Google 'raspberry pi gpio pinout' for more information.

Components

Firstly, get a BC618 transistor, which can handle up to 500 mA of continous current (ought to be good enough for my purpose). This little project also requires two resistors. One of the transistors is a pull down resistor, and can be around 2 to 5 kiloohms. The other resistor will make sure the transistor doesn't draw much current from the RPi, and it can be around 1 kiloohm.

You might want to use a breadboard while testing, before soldering stuff.

Detect humans

Next, you should decide how you're going to detect a human standing still in front of the mirror. I use an OMRON D6T MEMS Thermal Sensor for this. It actually senses the weak heat radiation coming from the human body, so it even works in the dark. Finally, write the sophisticated code that takes input from the sensor, processes it and wisely decides when the light should be on and when it should be off. I have some logic that decides when there's a human standing still in front of the mirror. In other words, the light does not turn on if somebody is moving, because somebody that just moves past the mirror does not need the mirror light. It would actually be just annoying and distracting if it would turn on when it should not. Also, in order to avoid blinking, I decide that I leave the light on for at least 2 seconds after the last time a human standing still in front of the mirror was detected.

Run script at startup

Run sudo crontab -e

Add a line like this: @reboot python /home/pi/auto-light/read_thermal.py

About

Home automation: Light that turns on when somebody is standing still in front of the mirror

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages