0

How do I connect a SPDT relay to an Arduino?

It's a DC 5V Coil 6 Pin relay and ultimately what I want to do is have the Arduino trigger the relay to allow voltage to pass through.

I couldn't find a data sheet, but apparently this is the layout...

----------------------------------
|....1......2..............3.....|
|................................|
|....4......5..............6.....|
----------------------------------

2 and 5 are the 5v relay coil
3 and 6 are shorted together
3 and 1 are normally closed
3 and 4 are normally open

enter image description here

  • datasheet for HT4100F. Current through the coil is at least 30mA, which is already above the recommended current for an Arduino pin. – Gerben Jun 30 '16 at 9:02
1

You can use this connection diagram with your relay

enter image description here

6 pin Relay pin out

enter image description here

Code

int Relay = 8;

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

void loop()
{
      digitalWrite(Relay, HIGH);  // turn on relay
      delay(2000);
      digitalWrite(Relay, LOW);   // turn off relay
      delay(2000);
}

First check your relay with multi meter then find the Coil, Com, NO and NC points for correct connection. Hope this will help you.

| improve this answer | |
0

According to the link you've provided, the coil draws very little current, and the person posting that comment suggests that it can be directly driven by an arduino. I would hesitate to use more than one to a board without additional research in that respect.

The comment also suggests that a capacitor be placed across the coil terminals, which will also protect your circuit from excessive power draw causing drop outs.

The research I've done indicates that the digital pins can handle a maximum of 40 ma, but the recommendation is no more than 20 ma, which is lower than the specs for this relay.

If you are going to use more than one on a given arduino board, a shift register or equivalent would protect your board and give you reliable results. For a single relay, consider this resource: https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/transistors

Some additional research may lead one to believe that even 20 ma is too much current to draw, so the transistor option is certainly the safer route.

Be certain to use pull-up or pull-down resistors, depending on your configuration with the digital pin selected.

You didn't indicate what you were going to be connecting to the N/O or N/C pins, but that won't matter if they are external to the arduino and do not exceed the specifications of the relay.

| improve this answer | |
0

Use a driver transistor (or MOSFET, with a 4K7 pull-down), and a flyback diode with the anode at the negative terminal, and cathode at positive terminal. I used some tiny ones, which failed, so now I use ones that can handle ~0.5A, but that's probably overkill.

If you want galvanic isolation, use an optocoupler instead of a transistor - I only do this for AC. I have never needed decoupling capacitors for this type of relay.

Edit:

  • Wire 5V to relay positive terminal.

  • Wire relay negative terminal to NPN transistor/MOSFET collector/drain.

  • Wire NPN/MOSFET emitter/source to GND. Wire NPN/MOSFET base/gate to some digital pin. If using a transistor, do it across a 1000 ohms resistor.

  • If using a N-channel MOSFET add a 4700 ohms pull-down from gate to GND.

  • Wire diode cathode to relay positive terminal, and anode to relay negative terminal.

I would not use the decoupling cap, but if OP really wants it, go for 50-100V 10uF.

| improve this answer | |
  • Any chance of a diagram? – Code Gorilla Apr 27 '17 at 7:19
  • The pulldown resistor is needed if you use some kind of FET transistor, but is is useless with an NPN. – Edgar Bonet Apr 27 '17 at 9:24
  • Yes, you're right. – user2497 Apr 27 '17 at 9:26

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.