Signal Relay 5vdc  - Page 1
Forum section: electronics / beginners

author: vidarr
author_rank: Frequent Contributor
timestamp: February 26, 2024, 08:05:27 pm
content: 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 secondsint Pump_off_time = 3; // Pump off time in secondsvoid 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!

author: vidarr
author_rank: Frequent Contributor
timestamp: February 26, 2024, 08:06:38 pm
content: The relays.

author: Andy Chee
author_rank: Super Contributor
timestamp: February 26, 2024, 08:15:17 pm
content: Quote from: vidarr on February 26, 2024, 08:05:27 pmI think I found the datasheet for you.

author: mariush
author_rank: Super Contributor
timestamp: February 26, 2024, 08:23:26 pm
content: 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) :

author: vidarr
author_rank: Frequent Contributor
timestamp: February 26, 2024, 10:19:04 pm
content: 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!

author: vidarr
author_rank: Frequent Contributor
timestamp: February 27, 2024, 07:21:35 pm
content: Can someone please check my schematic for mistakes, or if there are any improvements that could be made?Here are the datasheets:RL205 DIODEhttps://pdf1.alldatasheet.com/datasheet-pdf/view/191251/WTE/RL205.htmlPhotocouplerLTV-817https://www.mouser.com/datasheet/2/239/LTV-8X7_series_201610_-1544776.pdfPNP Epitaxial Silicon TransistorBC558https://www.onsemi.com/pdf/datasheet/bc556bta-d.pdfRELAY 5VHRS1KH-Shttps://www.farnell.com/datasheets/3795103.pdfTHANK YOU!!!EDIT:Arduino MEGA 2560THE PUMPhttps://yuanhuapump.en.made-in-china.com/product/RByQqHDonsWx/China-Submersible-Water-Fountain-Pump-Yh-400mix.html

author: Andy Chee
author_rank: Super Contributor
timestamp: February 27, 2024, 08:20:26 pm
content: 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.

author: vidarr
author_rank: Frequent Contributor
timestamp: February 27, 2024, 09:20:07 pm
content: 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!!!

author: Andy Chee
author_rank: Super Contributor
timestamp: February 27, 2024, 11:07:02 pm
content: Quote from: vidarr on February 27, 2024, 09:20:07 pmCorrect. 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.QuoteNope. 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.

author: vidarr
author_rank: Frequent Contributor
timestamp: February 28, 2024, 01:46:38 am
content: Excellent! Thank You!

author: vidarr
author_rank: Frequent Contributor
timestamp: February 28, 2024, 09:01:14 pm
content: 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-40https://www.arpe.com.br/produto/rele-industrial-12vdc-na-nf-15a-selado/The diode(s):RL205https://pdf1.alldatasheet.com/datasheet-pdf/view/191251/WTE/RL205.html

author: Andy Chee
author_rank: Super Contributor
timestamp: February 28, 2024, 09:17:36 pm
content: Temporarily remove the diode.Can you confirm that the relay energises with the power leads in both directions?

author: vidarr
author_rank: Frequent Contributor
timestamp: February 28, 2024, 10:33:27 pm
content: 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.

author: vidarr
author_rank: Frequent Contributor
timestamp: February 28, 2024, 11:05:03 pm
content: Pic.

author: shapirus
author_rank: Super Contributor
timestamp: February 28, 2024, 11:08:00 pm
content: Quote from: vidarr on February 26, 2024, 10:19:04 pmEven 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.

author: vidarr
author_rank: Frequent Contributor
timestamp: February 29, 2024, 12:07:23 am
content: "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!

author: Andy Chee
author_rank: Super Contributor
timestamp: February 29, 2024, 02:22:15 am
content: Quote from: vidarr on February 29, 2024, 12:07:23 amSolder 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.

author: sparkydog
author_rank: Regular Contributor
timestamp: February 29, 2024, 08:38:55 pm
content: Quote from: vidarr on February 28, 2024, 09:01:14 pmUnless 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.

author: Jwillis
author_rank: Super Contributor
timestamp: March 01, 2024, 01:46:18 am
content: Here's a datasheet for theOUAZ-SS-124LThe 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.

author: Zero999
author_rank: Super Contributor
timestamp: March 01, 2024, 11:03:44 am
content: Quote from: sparkydog on February 29, 2024, 08:38:55 pmAdding 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.

author: Jwillis
author_rank: Super Contributor
timestamp: March 01, 2024, 02:22:44 pm
content: 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

author: vidarr
author_rank: Frequent Contributor
timestamp: March 02, 2024, 08:04:14 pm
content: 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-transistorhttps://datasheet4u.com/datasheet-pdf/METALTEX/AX1RC2/pdf.php?id=1264798Thank 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.

author: shapirus
author_rank: Super Contributor
timestamp: March 02, 2024, 08:56:03 pm
content: 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?

author: vidarr
author_rank: Frequent Contributor
timestamp: March 03, 2024, 08:20:33 pm
content: 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.pdfChanged the transistor to model BC338:https://pdf1.alldatasheet.com/datasheet-pdf/view/2889/MOTOROLA/BC338-25.html

author: Jwillis
author_rank: Super Contributor
timestamp: March 03, 2024, 09:59:09 pm
content: 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.

author: shapirus
author_rank: Super Contributor
timestamp: March 04, 2024, 12:24:23 am
content: Quote from: vidarr on March 03, 2024, 08:20:33 pmMeh, I should have been more specific. Sorry for that. When I said "directly", of course I didn't mean that you should connect the base actually directly to +5V. It was "directly" in terms of controlling it from a known +5V signal, to rule out any posibility of the signal not being properly delivered by the arduino.If you connected the base to +5V without a resistor between the base and +5V, then of course the transistor would fry very quickly, as there wouldn't be anything to limit current flowing via the base-emitter p-n junction. Otherwise, no idea. Regarding the LED, it's hard to tell what could have happened without a schematic.

author: vidarr
author_rank: Frequent Contributor
timestamp: March 23, 2024, 08:08:07 pm
content: I got the entire circuit built and everything is working flawlessly, except, I am short one transistor. Researching around, I saw someone use an N FET where I was placing my NPN transistors. I have this PN4302, but the info about the other guy's circuit is very limited and most importantly, I don't know if it worked out for him.https://mm.digikey.com/Volume0/opasdata/d220001/medias/docus/721/PN4302.pdfThanks Everyone! All of your help is really appreciated.