-2

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, 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

BTW, here is a reference photo from Adafruit of how they have it wired.

enter image description here

  • the relay is just a switch .... it is like touching two wires together – jsotola Jun 8 '18 at 17:11
  • why are you posting at multiple sites? electronics.stackexchange.com/questions/378824/… – jsotola Jun 8 '18 at 17:43
  • Please give actual wiring diagrams, not pictures of breadboards, its to hard to tell how yours is wired, and the picture from adafruit is useless – Chad G Jun 8 '18 at 17:58
  • @mheavers crossposting is explicitly prohobited – Chris Stratton Jun 8 '18 at 18:04
  • @ChrisStratton - so do I delete this post? Stack exchange warns me that "deleting a post with answers deprives users of useful knowledge" - which I agree with. – mheavers Jun 8 '18 at 18:21
1

A relay is just a switch, that is controlled via a magnet force from coil. The power line to the relay breakout board is just used to drive enough current through this coil, since often the 20mA of a normal digital output pin aren't enough for that.

Relays are for switching big loads, that should not have contact with the microcontrollers circuit. You don't want the 230V (or 110V, depending on where you live) to find their way to the microcontroller. Also most boards can only provide a very limited amount of current. Big loads mostly need a lot of current and you don't want this big current flowing through the tiny copper traces on the board. You have to use an extra power supply for these.

So have to connect the relay like a normal switch, in series with the load you want to control with it. Also keep in mind the difference between the normally open and normally closed output of the relay. Here is a schematic, to explain further, what circuit you need:

schematic

simulate this circuit – Schematic created using CircuitLab

You provide power for the coil of the relay from the two power lines of the ESP (3.3V and GND). The digital pin, that you use for switching is just a signal. It only has to provide a very minimal amount of current. The board itself has a driver circuit to activate the coil. Here I used a simple MOSFET, but I actually don't know, what driver circuit is really used on that board.

If enough current is flowing through the coil, the switch inside the relay changes from NC (normally closed/connected) pin to NO (normally open) pin, closing the electrical circuit, that provide the big load (here a light bulb) with current from an external power supply (like a wall outlet). The two circuits are NOT electrically connected, so you won't have to deal with potential high voltage and current on the ESP side.


And in your sketch you don't ever turn the LED off. I assume this is just an error from copy/paste.

  • @chrisi - thanks for the clarification - I did miss a line of code copying and pasting. But I still don't understand how the circuit should be wired. I've been searching for a fritzing diagram or circuit diagram, but I can't find something that simplifies this process. – mheavers Jun 8 '18 at 17:35
  • @mheavers: I added a schematic and further explanations – chrisl Jun 8 '18 at 18:01
0

I don't see a current limit resistor in the LED circuit, 270 to 470 Ohms, must have. Also, there is no power supply for the LED, the relay is just a short circuit across the LED.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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