I'm working on a project but I'm having issues with a few components. I'm using 8 1.5V batteries to power a water pump or a LED light strip. I'm using a relay to control when the water pump/LED strip is turned on.
This small project is very much like this one. The only difference is the power supply is 12V DC.
The LED strip/Water pump does not turn on when the signal is sent to the relay and I'm not sure why this is the case. When I connect the + terminal of the LED strip/water pump to the normally closed terminal on the relay it is constantly on, which I would expect. I don't understand why when I connect the + terminal of the LED strip/water pump to the normally open terminal of the relay it does not turn on when I send the signal to the relay.
I'm at a loss and am quite perplexed. Can anyone provide an explanation?
I'll post the exact source code and a diagram of my connections later today.
I've seen a post online that suggest I run a diode and capacitor across the motor. I've seen other posts that suggest the diode, but made no mention of a capacitor. Can someone explain this? Also, would I need to do the same thing for an LED strip? My gut tells me no, but I'm a noobie so I can't trust my instincts here.
Attached are some actual pictures of the Arduino setup.
I may have figured out the issue, but I'm not sure. At the bottom of the relay I'm using it says "SRD-12VDC-SL-C" and the other post I referenced uses a relay that says "SRD-05VDC-SL-C"
If I'm correct that means the relay I'm using requires 12V while the relay in the referenced post only requires 5V to do so. Because the VCC pin on the relay is connected to the 5V pin on the arduino I may not be supplying enough power to the relay to make it switch. Is this true?
Hi,
You are on the right track, the relay is a 12v relay so using a transistor (type - using a transistor to operate a relay - into google) and your 12v battey pack it should work.
I am not good on code so have not looked at it. But the relay will not work as it is now.
Using the transistor takes the load off the output pin as well.
You should always check to see that the device connected does not draw more current than the pin can supply.
Why using a relay when a MOSFET type switch would do just fine without wasting precious battery power on a relay coil?
Anyway with the relay being a 12V type you need to supply 12V to the coil - and that means you need a transistor driver between the Arduino and the relay itself already. Your Arduino may or may not be able to power a small relay by itself, it for sure can't power a 12V relay by itself as it doesn't produce 12V.
Thanks everyone for the replies. I'm new so I don't always know the best way. I've order some transistors to replace the relay. I also ordered some 5V relays as well because they're cheap. Once I get the parts in and try them out I'll post an update.
I do have one question. When is it a good idea to use a relay vs a transistor?
Thanks again guys, I appreciate the support. I'm new and I hardly know what I'm doing. I can't do this without your input.
For me it's use transistors where you can, relay where you must.
Advantages of a relay are that they have virtually no resistance vs. 0.1 Ohm or so for a power MOSFET, and that they provide electrical isolation. So they're great switching big loads and high voltages, including mains power.
Advantage of a transistor (usually MOSFET type for switching) is that they're silent, fast, and in case of MOSFETs don't take much if any current from the control pin. Relays often need external power supply, and again a transistor to switch them even if the relay works at 5V.
Advantage of a relay is you just plug it in and use the normally open or closed. No worry about having to wiring p or n type or anything like that it’s a no brainer. I like relays because I am an industrial controls designer and relays are what are used in control cabinets. If I were to design something like your project I would use the mosfet.