Controlling Christmas Lights with the Intel Edison + Grove Smart Relay

This Instructable guides you through the process of using the Intel Edison board and the Grove Smart Relay to control Christmas lights (or any other electronic item for that matter).

At the end of this Instructable, you will have a electrical outlet wired to only have power flowing to it when the relay is closed by the Edison board.

Step 1: Materials

Controlling Christmas Lights with the Intel Edison + Grove Smart Relay

What you need:

  • Computer with the Intel Arduino IDE and associated drivers installed
  • Intel Edison Board
  • USB to Micro USB cable
  • Grove Base shield
  • Grove Smart Relay
  • Grove Button
  • Grove connector cables x2
  • Bare outlet
  • Power cord you don't mind cutting up
  • Screwdrivers x2 (small phillips and large phillips)
  • Electrical Tape (for your own safety!)
  • Christmas lights, or something else to plug into the outlet

    Step 2: Safety Warning!

    WARNING!

    You will be interacting with household electricity which runs at 120V. This stuff hurts (I know this from experience), so please follow these steps to keep you safe.

    What you shouldn't do:
    DO NOT plug anything into the wall until you are finished wiring and covering everything
    Which means:

  • DO NOT leave the pins on the Smart Relay exposed
  • DO NOT leave wires or connections exposed

    What you should do:

  • DO wire the Smart Relay into the hot wire (the one where the electricity flows from) before the outlet. This keeps electricity out of the outlet until the relay is closed.
  • DO cover exposed wires and connectors with electrical tape
  • DO insulate the back of the relay with something non-conductive (e.g. cardboard)

    Okay! Now that we have that out of the way, let's get started!

    Step 3: The Plan

    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay

    The plan is to integrate the relay into the circuit we make between the bare outlet and the wall socket.

    Relays work by acting like a bridge across the two wires connected to it. When the relay is open/off, the is no physical connection between the two wires, meaning that electricity does not flow. When the relay is closed/on, the wires are connected within the relay, and electricity can flow. The relay's switch is controlled by signals sent from the Edison board. If the Edison writes a HIGH signal on the pin controlling the relay, the relay closes. Likewise, if the Edison writes a LOW signal to the control pin, the relay opens. This mechanism is what allows us to control 120V+ electronics using only the 5V power of the Edison board.

    If you house is wired correctly, the short slot is hot. This means that the electricity flows out of that slot, through the plug, down the wire, and into whatever the wire is connected to. The electricity then returns along the wire into the neutral slot.

    While we could put the relay at any point in the circuit, we want to put the relay in between the wall socket and outlet on the hot wire. This prevents electricity from entering the outlet at all when the relay is open. This is a good idea, since we don't want to accidentally shock ourselves from the outlet.

    Step 4: Prepping the Wires

    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay
    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay
    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay

    First thing you need to do is figure out which wire in your cord is the hot wire. I lucked out with mine because the entire cord is transparent, so I could just follow the wire all the way down. You can also use a voltmeter to find out which one is carrying current by plugging the cord in, touching the red lead to the end of the wire, and touching the black lead to either the neutral or ground slot in the outlet.

    Now that we know which wire is which, we need to strip the ends of the wires, as well as cut a small length of wire for the connection between the relay and the outlet.

    I cut myself about 8-10 inches of wire from the hot wire and left myself about a foot of free wire on the neutral end.

    You don't need any exact measurements, but leave yourself enough slack that you can easy attach things.

    Step 5: Insulating the Relay

    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay
    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay

    You really don't want to have exposed pins on the relay. Those pins are carrying 120V, and it does not feel nice to touch them accidentally.

    Do yourself a favor and push the pins through some cardboard (sometimes you'll need 2 or more sheets because the pins are long) and tape that sucker up. This will nicely insulate those electrified pins.

    Step 6: Wire the Relay

    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay

    This step is pretty straightforward.

  • Loosen the two screws above the wire slots
  • Take your hot wire from the plug and feed it into either slot (I chose the right one)
  • Tighten the screw above the wire to lock it in place
  • Take one of the ends of your cut wire and feed into the other slot
  • Tighten the screw above the wire to lock in place

    Voila! You wired the relay!

    Step 7: Wire the Outlet

    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay
    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay
    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay

    On the back of the outlet, it usually has some text the tells you which side you should attach the hot wire to and which side you attach the neutral wire to.

    Once you identify which side is which, go ahead and screw the wires down.

    After everything is snug, wrap it with electrical tape. Make sure all the metal contacts on both sides are covered well.

    Step 8: Setting up the Edison

    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay

    Connect the relay to the slot marked D6 and either the touch sensor or the button to the slot D3 with the 4-pin connector cables. The touch sensor/button will be used to trigger the relay to open and close.

    You've done the hardware setup, now comes the software!

    Boot up your PC, connect the Edison with the USB cable (using the inside Micro-USB port), and upload this sketch:

    // Expanded Edison Relay Demo

    const int buttonPin = 3; // the button is attached to digital pin 3 const int relayPin = 6; // the relay is attached to digital pin 9 const int pinLed = 13; // pin of led define here

    int buttonState = 0;

    void setup() { pinMode(relayPin, OUTPUT); pinMode(buttonPin, INPUT); pinMode(pinLed, OUTPUT); // set led OUTPUT }

    boolean released = false; void loop() { // read the state of the button: buttonState = digitalRead(buttonPin); if (buttonState == 1) { if(released == true) { digitalWrite(relayPin, HIGH); digitalWrite(pinLed, HIGH); // led on released = false; } } else { if(released == false) { digitalWrite(relayPin, LOW); digitalWrite(pinLed, LOW); // led on released = true; } } //delay(10); }

    This script will turn on the relay when the button/touch sensor is pressed and turn it off when the button/touch sensor is released.

    Step 9: Test the Edison

    The nice thing about this setup is that you can test it without having it plugged in!

    Once you have the button and relay connected, along with the sketch uploaded, you can go ahead and press the button. You should hear a nice, solid click coming from the relay. You should also see the onboard LED on the Edison light up, and the LED on the relay light up. When you release the button, the relay should click again and the LEDs should turn off.

    That click you are hearing is the physical switch in the relay being closed and opened by the control signal.

    Troubleshooting:

  • If you don't hear a click and the LED on the relay doesn't turn on,but the onboard LED lights up, make sure the Grove Base Shield is set to 5V. The relay doesn't function on 3.3V.
  • Check to make sure the button and relay are connected to the right ports on the base shield.
  • Try restarting the Base Shield by pushing the side button.

    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay
    VID_20141230_122141094[1].mp4(516x290) 37 KB

    Step 10: Plug it in!

    The time has come! Plug in the power cord to a wall outlet.

    With the Edison powered on, try pressing the button. You should hear that nice click and you should see the lights turn on!

    Controlling Christmas Lights with the Intel Edison + Grove Smart Relay
    VID_20141230_124445724[1].mp4(402x714) 38 KB

    Step 11: Expand!

    Now that you have a outlet being powered by a button press, you can expand your project to respond to other sensors. For example, you could wire up a light sensor to automatically turn on the lights once it get's dark enough. Or you could wire up a sound sensor and make yourself a nice burglar alarm!

    The sky is the limit!

  •  
     

    Tag cloud

    make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel