Author Topic: Signal Relay 5vdc  (Read 1530 times)

0 Members and 1 Guest are viewing this topic.

Offline vidarrTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: br
Signal Relay 5vdc
« on: February 26, 2024, 08:05:27 pm »
Hey guys,

I need a relay to turn on a pump for an auquaponic system. The board I am using is an Arduino MEGA 2560 (5VDC) and the pump is a standard submersible pump (YH-400MIX 120VAC). Is it possible to reuse one of these relays I salvaged? The one I would like to use is the HRS1KH-S 5VDC. I cannot find a datasheet with an example schematic though, so I don't know how to design the relay portion of the circuit (I don't know which pins are which).

There are a total of five pins on the bottom. Two pins above two pins and a single pin in a corner. If this wasn't using mains power I would be a lot less nervous.

The code is pretty straight forward (the times will change for the final.):

int Pump_pin = 7;
int Pump_on_time = 2; // Pump on time in seconds
int Pump_off_time = 3; // Pump off time in seconds

void setup()
{
Serial.begin(9600);
pinMode(Pump_pin, OUTPUT);
}
void loop()
{
Pump (); //Switch pump on and off
}
void Pump ()
{
digitalWrite(Pump_pin, HIGH);
Serial.println("Pump on");
delay(Pump_on_time * 1000);
digitalWrite(Pump_pin, LOW);
Serial.println("Pump off");
delay(Pump_off_time * 1000);
}

THANK YOU!
 

Offline vidarrTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: br
Re: Signal Relay 5vdc
« Reply #1 on: February 26, 2024, 08:06:38 pm »
The relays.
 

Offline Andy Chee

  • Frequent Contributor
  • **
  • Posts: 686
  • Country: au
Re: Signal Relay 5vdc
« Reply #2 on: February 26, 2024, 08:15:17 pm »
I cannot find a datasheet with an example schematic though, so I don't know how to design the relay portion of the circuit (I don't know which pins are which).
I think I found the datasheet for you.
 
The following users thanked this post: vidarr

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5029
  • Country: ro
  • .
Re: Signal Relay 5vdc
« Reply #3 on: February 26, 2024, 08:23:26 pm »
You don't power a 5v relay directly from the microcontroller pin, because a pin can't provide enough current.   A 5v relay needs something like 80-150mA to stay engaged, while a 12v relay needs only around 30-40mA.

A single microcontroller pin is good for around 10-20 mA and in total through multiple pins your microcontroller is probably good for 100-150mA.

You would use a npn transistor - turn on and off the transistor which connects the relay to ground - one side of the relay is connected to 5v or whatever voltage, the other to the transistor collector, the emitter is connected to ground .. and you connect the base of the npn transistor to the arduino pin through a resistor (something like 10-100 would be fine)

Because your microcontroller only interacts with the base of the transistor and uses 3.3v or 5v the microcontroller runs on, you can have the relay powered with a higher voltage like 12v for example.

See this video where he uses a transistor to turn on and off a solenoid (works the same as a relay) :

 

« Last Edit: February 26, 2024, 08:33:09 pm by mariush »
 
The following users thanked this post: vidarr

Offline vidarrTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: br
Re: Signal Relay 5vdc
« Reply #4 on: February 26, 2024, 10:19:04 pm »
I was going to copy this schematic attached. Where I am confused is about the Normally open (NO) and normally closed (NC). I finally saw the bottom of the relay on the datasheet, I completely missed it before... So, I understand it a little better, I know which pin is the COM, but don't know which pin is the NO and the NC. I am about to watch the video --Thank you for that.

Also, I see a lot of designs that use an optocoupler. I know what it is for, but is this really necessary?

THANK YOU!

 

Offline vidarrTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: br
Re: Signal Relay 5vdc
« Reply #5 on: February 27, 2024, 07:21:35 pm »
Can someone please check my schematic for mistakes, or if there are any improvements that could be made?

Here are the datasheets:

RL205 DIODE
https://pdf1.alldatasheet.com/datasheet-pdf/view/191251/WTE/RL205.html

Photocoupler
LTV-817
https://www.mouser.com/datasheet/2/239/LTV-8X7_series_201610_-1544776.pdf

PNP Epitaxial Silicon Transistor
BC558
https://www.onsemi.com/pdf/datasheet/bc556bta-d.pdf

RELAY 5V
HRS1KH-S
https://www.farnell.com/datasheets/3795103.pdf


THANK YOU!!!

EDIT:

Arduino MEGA 2560

THE PUMP
https://yuanhuapump.en.made-in-china.com/product/RByQqHDonsWx/China-Submersible-Water-Fountain-Pump-Yh-400mix.html
« Last Edit: February 27, 2024, 07:24:06 pm by vidarr »
 

Offline Andy Chee

  • Frequent Contributor
  • **
  • Posts: 686
  • Country: au
Re: Signal Relay 5vdc
« Reply #6 on: February 27, 2024, 08:20:26 pm »
It's possible that your application does not require the optocoupler, so your circuit could potentially be simplified to this:



But your circuit will work as is.

There are several different reasons to use optocouplers, but none seem particularly applicable to you.
 
The following users thanked this post: vidarr

Offline vidarrTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: br
Re: Signal Relay 5vdc
« Reply #7 on: February 27, 2024, 09:20:07 pm »
That would simplify things for sure. The relay is used/salvaged and I don't know how many hours are on it. The pump is 120VAC and I was nervous about blowing my Arduino Mega.

I am building the circuit on a breadboard now. I will replace the Arduino with a simple switch to test it out first and leave the optocoupler out.

A couple questions:

In your schematic, are you saying I should ground the Arduino with/to the external, 5VDC power supply?

And also, if I need to change the external power supply to 12VDC and the relay to a 12VDC capable (if it fails, I only have the one 5VDC Relay and a pile of 12VDC Relays), would this require an optocoupler?

Thank You!!!
« Last Edit: February 27, 2024, 10:00:33 pm by vidarr »
 

Offline Andy Chee

  • Frequent Contributor
  • **
  • Posts: 686
  • Country: au
Re: Signal Relay 5vdc
« Reply #8 on: February 27, 2024, 11:07:02 pm »
In your schematic, are you saying I should ground the Arduino with/to the external, 5VDC power supply?
Correct.  The ground of the Arduino and the ground of your relay coil VCC, MUST be connected together for the simplified schematic to work.

On the other hand, your optocoupler version can work with separate grounds.

Quote
And also, if I need to change the external power supply to 12VDC and the relay to a 12VDC capable (if it fails, I only have the one 5VDC Relay and a pile of 12VDC Relays), would this require an optocoupler?
Nope.  The simplified schematic will still work with a 12VDC relay coil VCC.  Optocoupler not necessary.

Oh, a word of warning about the mains wiring.  When you design your circuit board, make sure you don't route the low voltage coil traces and Arduino traces, anywhere near the mains voltage wiring.  You can post a picture of your PCB design here for review.
« Last Edit: February 27, 2024, 11:11:07 pm by Andy Chee »
 
The following users thanked this post: vidarr

Offline vidarrTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: br
Re: Signal Relay 5vdc
« Reply #9 on: February 28, 2024, 01:46:38 am »
Excellent! Thank You!
 

Offline vidarrTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: br
Re: Signal Relay 5vdc
« Reply #10 on: February 28, 2024, 09:01:14 pm »
Working on a final circuit after some component changes and I am having an issue with connecting the relay. I am just testing the relay without the transistor, but the power leads and diode to the coil should work the same(?).

In the attached picture, the relay switches on (notice the direction of the diode). If I turn that diode around (the way it is shown in the schematic), I also have to turn the +/- power leads around too, or the relay won't switch ON. I must be missing something really simple.

(If I understand the theory right, with the cathode connected to the collector of the transistor, the discharge of the collapsing magnetic fields and voltage spike will be flowing right into the collector, which is what the diode is supposed to be preventing, protecting against.)


Thanks!

The new relay(s):
ya303h-c-12v-40
https://www.arpe.com.br/produto/rele-industrial-12vdc-na-nf-15a-selado/

The diode(s):
RL205
https://pdf1.alldatasheet.com/datasheet-pdf/view/191251/WTE/RL205.html

 

Offline Andy Chee

  • Frequent Contributor
  • **
  • Posts: 686
  • Country: au
Re: Signal Relay 5vdc
« Reply #11 on: February 28, 2024, 09:17:36 pm »
Temporarily remove the diode.

Can you confirm that the relay energises with the power leads in both directions?
 
The following users thanked this post: vidarr

Offline vidarrTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: br
Re: Signal Relay 5vdc
« Reply #12 on: February 28, 2024, 10:33:27 pm »
Yes. It works in both directions ---12VDC in both directions.

Right now, I am am about to solder the diode to the Relay.

edit: It is working now, but with another relay. I don't know what the issue was with the "original" relay, so I put it in the garbage.

I went with these relays because I decided to use my 12VDC PSU (in Pic) that has been collecting dust and I have five, working, ya303h-c-12v-40 relays (in Pic). This will allow me to have five channels that the aquaponics setup can grow into.

And I changed the transistors to the C945 NPN.

Otherwise, the schematic is going to stay the same.

Thank You so much!

I will post the circuit when I finish.
« Last Edit: February 28, 2024, 11:03:31 pm by vidarr »
 

Offline vidarrTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: br
Re: Signal Relay 5vdc
« Reply #13 on: February 28, 2024, 11:05:03 pm »
Pic.
 

Online shapirus

  • Super Contributor
  • ***
  • Posts: 1354
  • Country: ua
Re: Signal Relay 5vdc
« Reply #14 on: February 28, 2024, 11:08:00 pm »
Where I am confused is about the Normally open (NO) and normally closed (NC). I finally saw the bottom of the relay on the datasheet, I completely missed it before... So, I understand it a little better, I know which pin is the COM, but don't know which pin is the NO and the NC. I am about to watch the video --Thank you for that.
Even if there's no datasheet, you can always use a DMM in resistance mode to find the coil terminals: it will have some reasonable resistance like 50-1000 Ohm depending on the nominal coil operating voltage (which is usually known from the marking) and the relay's size/contact current handling capability.

The NC and NO terminals can be found using the DMM again, in resistance or continuity mode, and then again checked how they are switched when the coil is energized.

And even if you do have the datasheet, it never hurts to double check that the actual relay you have, especially if it's used and/or is of dubious origin, matches the datasheet.
 
The following users thanked this post: vidarr

Offline vidarrTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: br
Re: Signal Relay 5vdc
« Reply #15 on: February 29, 2024, 12:07:23 am »
"The NC and NO terminals can be found using the DMM again, in resistance or continuity mode, and then again checked how they are switched when the coil is energized.'

Thank you, I am getting to this step right now. It didn't make sense that the NO and NC were not labeled until I realized all the different ways the whole circuit could be designed and the coil can be wired either way (also not labeled, of course). Plus, I get nervous with 120VAC.

Also, how do you work with 120VAC pins on the relay when they are right next to each other (see pic)? All the examples I see show at least one "space" between the pins.
(Of course, I am not going to plug 120VAC into the breadboard! I just used it for scale.)

Thanks!
 

Offline Andy Chee

  • Frequent Contributor
  • **
  • Posts: 686
  • Country: au
Re: Signal Relay 5vdc
« Reply #16 on: February 29, 2024, 02:22:15 am »
Also, how do you work with 120VAC pins on the relay when they are right next to each other (see pic)?
Solder some wires to the pins and heatshrink some insulation around them.  Then put the wires into terminal blocks.  This should suffice for the purposes of prototyping.  For a permanent solution you will need a PCB.
 
The following users thanked this post: vidarr

Offline sparkydog

  • Regular Contributor
  • *
  • Posts: 234
  • Country: us
Re: Signal Relay 5vdc
« Reply #17 on: February 29, 2024, 08:38:55 pm »
(If I understand the theory right, with the cathode connected to the collector of the transistor, the discharge of the collapsing magnetic fields and voltage spike will be flowing right into the collector, which is what the diode is supposed to be preventing, protecting against.)

Unless your transistor is really touchy (or you're penny pinching), I would recommend using a TVS instead of a plain diode. The relay will open faster and with somewhat reduced risk of contact welding.
 
The following users thanked this post: vidarr

Online Jwillis

  • Super Contributor
  • ***
  • Posts: 1710
  • Country: ca
Re: Signal Relay 5vdc
« Reply #18 on: March 01, 2024, 01:46:18 am »
Here's a datasheet for the OUAZ-SS-124L
The dielectric strength of air is 3 kV/mm so having pins 2.5mm apart for 120V is fine. For prototyping, just put some insulation like electrical tape over the solder connections if your worried. On a PCB you could add a slot cut between the 2 pins that are close together. If the relay is used primarily as a switch (On/Off) then it's permissible to clip the unused pin. 
 
The following users thanked this post: vidarr

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19527
  • Country: gb
  • 0999
Re: Signal Relay 5vdc
« Reply #19 on: March 01, 2024, 11:03:44 am »
(If I understand the theory right, with the cathode connected to the collector of the transistor, the discharge of the collapsing magnetic fields and voltage spike will be flowing right into the collector, which is what the diode is supposed to be preventing, protecting against.)

Unless your transistor is really touchy (or you're penny pinching), I would recommend using a TVS instead of a plain diode. The relay will open faster and with somewhat reduced risk of contact welding.
Adding a resistor in series with the diode is another way to improve the turn off time, but it will increase the voltage seen by the transistor, by ICOIL*R. In other words, if the power supply voltage is 12V and the relay draws  10mA, a 2k resistor would increase the voltage by 0.01*2000 = 20V, so the transistor will need to be able to handle the supply voltage + 20V = 12+20=32V.
 
The following users thanked this post: vidarr

Online Jwillis

  • Super Contributor
  • ***
  • Posts: 1710
  • Country: ca
Re: Signal Relay 5vdc
« Reply #20 on: March 01, 2024, 02:22:44 pm »
A thing  to consider when working with relays is the type of load you intend on switching. The contact point ratings listed for a particular relay are based on  resistive loads and don't consider inrush currents. When dealing with inductive, capacitive and other types of loads, you may need to Derate your relay to avoid damaging it. Depending on the motor you may need to derate as much as 20% the resistive rating of the contact points.
Take a look at this as they can explain it much more clearly than I can. Maximizing the Life Span of Your Relays
 
The following users thanked this post: bingo600, vidarr

Offline vidarrTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: br
Re: Signal Relay 5vdc
« Reply #21 on: March 02, 2024, 08:04:14 pm »
Something is wrong with the circuit. I tested it out on the breadboard first and it worked, but I must have made a mistake in the build. The relay still switches when I apply the 12VDC to the coil. I think the problem is with the transistor hookup. When I try to switch the relay thru the transistor with 5VDC, it does not work. I am using the Arduino pins for the 5VDC + and GND to test.

The built circuit and schematic is attached. Ignore the LEDs in the circuit, they are not soldered into place yet.

datasheets:
https://components101.com/transistors/2sc945-bipolar-npn-transistor

https://datasheet4u.com/datasheet-pdf/METALTEX/AX1RC2/pdf.php?id=1264798

Thank You for All your Help Guys!

edit: the two purple lines going to the edge of the board are going to the common ground that runs the length of the board. The standard generic board style.
« Last Edit: March 02, 2024, 08:08:05 pm by vidarr »
 

Online shapirus

  • Super Contributor
  • ***
  • Posts: 1354
  • Country: ua
Re: Signal Relay 5vdc
« Reply #22 on: March 02, 2024, 08:56:03 pm »
Looks right to me, it should work. Did you try to apply +5V to the base resistor directly, not via the arduino, to exclude one possible source of problems? If you don't have a convenient +5V source, you can use the same +12V, but change the resistor to 2k.

Is the transistor still alive and good?
 
The following users thanked this post: vidarr

Offline vidarrTopic starter

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: br
Re: Signal Relay 5vdc
« Reply #23 on: March 03, 2024, 08:20:33 pm »
Yes, it is possible the transistor went bad. When I tested it again by connecting the 5VDC PSU leads to the transistor and common ground, it blew an LED that was in the circuit before the transistor. Going "reverse", it was the transistor, then a 230 Ohm resistor, then an LED and the positive of the LED was connected to nothing. I put the 5vdc psu lead to the base of the transistor and the psu gnd to the common gnd and the LED blew out loudly. POP! Odd?

Anyway I got it working again, but only after I switched out the transistor for a BC338. I also added a diode to the circuit that the Arduino digital pin goes thru before the transistor, to protect the Arduino. Not sure if this actually protects the Arduino, but it seemed like an OK idea --especially after that LED blew out. The circuit is working. ----- Anyone, Please let me know if this actually Protects the Arduino. -------

Because the other transistor is Japanese, the pins are in a different configuration, so, unfortunately, I will have to de-solder the circuit and redo it with the new, BC338 transistor.

Let's see if it works this time around. If so, I will build all five channels/five relays.

Thanks!

1N4007 the added Diode to possibly protect the Arduino:
https://www.diodes.com/assets/Datasheets/ds28002.pdf

Changed the transistor to model BC338:
https://pdf1.alldatasheet.com/datasheet-pdf/view/2889/MOTOROLA/BC338-25.html
 

Online Jwillis

  • Super Contributor
  • ***
  • Posts: 1710
  • Country: ca
Re: Signal Relay 5vdc
« Reply #24 on: March 03, 2024, 09:59:09 pm »
You can add a 5V Zener from ground to before the 1K Base resistor. If the transistor fails then the Zener will only allow 5V back to the Arduino. You could even use a lower value Zener  like 4.9V or even 4.3V since the transistor is current controlled and does not require the full 5V to operate. The 1K resistor will limit the current passing the Zener during a fault.

You can use any transistor providing that the Power Dissipation isn't exceeded. So knowing the current required to activate the relay coil. Coil current multiplied by the Vce of the transistor to give the power in watts that the transistor needs to dissipate.   
« Last Edit: March 03, 2024, 10:03:31 pm by Jwillis »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf