Home Automation: Control Relay Base on Light Sensor (Intel Edison)

by Nghia Nguyen in Circuits > Electronics

5862 Views, 48 Favorites, 0 Comments

Home Automation: Control Relay Base on Light Sensor (Intel Edison)

IMG_2594.JPG
IMG_2604.JPG
IMG_2605.JPG

Hi everyone, in this instructable, I will show you how to make your home smarter.

Every night before go to bed, you always have to turn on the alarm system. So, in this project, I will use the light sensor to detect whether the light of your room has been turned off, means that you are going to sleep soon. Then, the Edison will turn on the relay and activate the alarm system. Now, let's get started!

Parts You Will Need

IMG_2597.JPG
IMG_2595.JPG
IMG_2596.JPG

You will need the Intel Edison Board and the Grove Starter Kits, specifically:

- Intel Edison

- Edison Arduino Expansion Board

- Grove Base Shield

- Grove LED Socket and a LED

- Grove Relay

- Grove Light Sensor

Hardware Connection

IMG_2603.JPG
IMG_2593.JPG

- Make sure you connect the LED to the socket with right + and - pin.

- Use the bus cable in the Grove Starter Kit to connect the relay, LED, and light sensor to the Base Shield:

- Relay ---> D2

- LED ---> D3

- Light Sensor ---> A0

That's all you need! Let's move to next step!

Some Useful Information About the Grove Starter Kit

devkit.jpg

We should take about 5 mins to gather some info about relay operation and the light sensor we are using.

- The Relay works the same way as a momentary switch, but with digital control. Specifically, when you set the input signal to 1 (pull up to VCC), it connects the two ports of the screw terminal, the switch is on just like when you push a button, so the circuit is connected. Set 0, the switch is released, and the circuit is opened.

- There are 2 things to consider when using a relay: a max current coming through and the max voltage between 2 heads. The Grove relay is claimed to have 10A max current at 250V max voltage operation, but the PCB circuit as well as the screw terminal cannot handle that much because they are too small. Thus, I only use it as prototype, and not wire it to home high-voltage alarm system.

- The light sensor is actually a photo-resistor - a resistor that changes its value based on light intensity.

Hope you will find some interesting information! Now let's start coding!

Let's Try the Code

Screen Shot 2015-02-13 at 9.08.20 PM.png
Screen Shot 2015-02-13 at 9.07.42 PM.png
Screen Shot 2015-02-13 at 9.07.57 PM.png

Here is how it works:

When you you move the finger into the sensor, the LED will dim according to the reduction of light intensity. When you move close enough, Edison will turn on the relay. Besides, you can open the Serial Monitor in Arduino Edison compiler to view the all the sensor and output status.

You can use this serial monitor to follow and adjust the light sensitivity.

First, you have to add Grove library, download it here: https://github.com/Seeed-Studio/Sketchbook_Starter...

I suggest you should read my earlier instructable to know how to add library as well as configure some basic things, here: https://www.instructables.com/id/Intel-Edison-IoT-C...

Now, import my project and enjoy the result!

If you have trouble, just comment here and i will help you solve it! Good luck, guys!