-2
\$\begingroup\$

I am trying to learn how to control a relay to power various household objects. I bought a power relay shield for an adafruit feather huzzah (esp8266), and I have just set up the arduino blink sketch to provide conditional high / low to a control pin on the relay:

const int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop {
    digitalWrite(ledPin, LOW);
    delay(1000);
    digitalWrite(ledPin, HIGH);
    delay(2000);
}

If I connect a jumper from the signal pin hole on the board to the appropriate ledPin (13), I can hear the relay switching on and off. If I use a multimeter in continuity mode, it will register continuity at the appropriate times in the blink sketch (HIGH or LOW).

I might be confused on how the relay should be wired, but shouldn't attaching wires from two of the terminal blocks deliver power to something? If I use a multimeter on wires coming out of the blocks, I don't detect any current. I've tried powering a simple led, but I can't get it to light up. Here's my setup. Can anyone explain what I might be doing wrong? Does the LED need a separate power source apart from what's coming from the feather itself? (the feather is powered by a USB cable from my computer).

Thanks for any clarification anyone can provide.

enter image description here

Here is a reference photo of how adafruit has things wired.

enter image description here

Here's an update of my implementation - let me know if anything looks wrong/dangerous. Thanks!

Fritzing Actual wiring

\$\endgroup\$
  • \$\begingroup\$ The relay doesn't supply power to the LED. The relay is only a switch to turn on power to the LED. I don't see any place for your LED to receive power. \$\endgroup\$ – JRE Jun 8 '18 at 17:00
  • \$\begingroup\$ @JRE - I attached a reference photo from adafruit - the only difference I see is that they are powering the relay / light from a LIPO rather than a USB cable from a laptop. Shouldn't my setup work as well? \$\endgroup\$ – mheavers Jun 8 '18 at 17:04
  • \$\begingroup\$ @mheavers No, the Adafruit photo shows that they've cut the power cord for something and inserted the relay inline. That's a bit dubious for an AC mains cord without additional protection around the relay, but the point is that the relay is breaking or completing some other circuit consisting of a power source and a load. A relay is just a switch (typically spring return style), with an electromagnet rather than your finger to flip it. \$\endgroup\$ – Chris Stratton Jun 8 '18 at 17:16
  • 1
    \$\begingroup\$ why are you posting at multiple sites? arduino.stackexchange.com/questions/53443/… \$\endgroup\$ – jsotola Jun 8 '18 at 17:42
4
\$\begingroup\$

Thanks for the picture. From what I can see, your wiring is wrong, possibly because your mental model of a relay is wrong.

The relay will connect the center post to one or the other posts. One output is called "normally closed" and is connected to the center when the relay is not energized, the other is called normally open and is connected to the center post when the relay is energized.

so your circuit is basically this:

schematic

simulate this circuit – Schematic created using CircuitLab

This schematic should make it obvious why there is no current going through your LED.

edit this is one way you could make it work:

schematic

simulate this circuit

\$\endgroup\$
  • \$\begingroup\$ Sorry - for your side note - I forgot the line of code which is setting the pin LOW - I'm assuming that is now correct. But as for your circuit, I'm still confused. I assume from your diagram that the top post on the relay is the COM (center) post, and the bottom two are NC and NO(?). If so, I'm assuming that when the relay is switched to the left bottom post, there will be no current, and when switched to the right bottom, it will complete the circuit and light the LED, correct? If so, how is this different from what I'm doing? \$\endgroup\$ – mheavers Jun 8 '18 at 17:25
  • 1
    \$\begingroup\$ When the relay is switched to the right bottom post, it's just connecting one end of the LED to the other. There's no power source in that circuit. (The dashed line in the relay symbol is not an electrical connection, it's an indication that the coil is what makes the switch move.) \$\endgroup\$ – Jeanne Pindar Jun 8 '18 at 17:28
  • \$\begingroup\$ Any chance I can see a diagram of how this circuit should work / be powered? \$\endgroup\$ – mheavers Jun 8 '18 at 17:33
  • \$\begingroup\$ @mheavers, I was hoping you'd be able to get to the solution by yourself. I have edited my post with one possible circuit. In this case the LED should turn on when the relay is energized. Note that the control side (arduino) and the "power" side (led) can be totally isolated, or you could use the same power source on both sides. I hope it helps! \$\endgroup\$ – MAB Jun 8 '18 at 18:01
  • \$\begingroup\$ I was able to get this working with the posted solution! I updated my question with photos / fritzing of my actual implementation. I'd love to hear any feedback on anything that might still look off though. Because I want to start working with things that have a bigger power draw, I want to make sure I understand fully how to wire things properly. \$\endgroup\$ – mheavers Jun 8 '18 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.