Powering multiple components from 5V Arduino Pin

I am trying to power a 12V DC pump using my Arduino, seen in this tutorial: Pump Tutorial

The relay used in the tutorial uses the 5V pin from the Arduino. However, I also wanted to use this 5V to power a HC-SR04 distance sensor.

Am I able to use the one 5V pin to power both the distance sensor and the relay? How would I go about setting this up safely and correctly? (Breadboard, twisting wires together?)

Thanks!

Hi,
OPs tutiorial picture.


The relay will only draw current to drive the control side of the relay, it should be okay as long as you have a 5V supply to the UNO.
If you are going to use 12V plugged into the DC socket, those two devices should be okay, but I would suggest not adding any more load to the UNO 5V pin.

Tom... :slight_smile:

TomGeorge:
Hi,
OPs tutiorial picture.


The relay will only draw current to drive the control side of the relay, it should be okay as long as you have a 5V supply to the UNO.
If you are going to use 12V plugged into the DC socket, those two devices should be okay, but I would suggest not adding any more load to the UNO 5V pin.

Tom... :slight_smile:

Thank you! Would powering my Arduino from a 9V battery work for this project? Even if I am using both a relay and HC-SR04?

Hi,
If the battery is a 9v PP3, like a smoke detector battery, then no, the battery will work for a short amount of time but is not designed for these sort of loads and does not have a large capacity.

A USB power wall unit will work, they are usually about 200mA or more these days and be possibly more conveinient.

Tom… :slight_smile:

TomGeorge:
Hi,
If the battery is a 9v PP3, like a smoke detector battery, then no, the battery will work for a short amount of time but is not designed for these sort of loads and does not have a large capacity.

A USB power wall unit will work, they are usually about 200mA or more these days and be possibly more conveinient.

Tom... :slight_smile:

I am already using a 12V DC power unit to power the Peristaltic pump. Is there any way that I can use only 1 power wall adapter in this type of project? I just don’t want to plug in 2 power units. Thanks for your help.

The Uno can handle 12V on the Vin pin, but the regulator will overheat very quickly when the load of the relay is added.

Best solution here is to get a 12V-5V buck converter. You can find them cheaply on your favourite online electronics shopping site (Taobao, Element14, Ebay, etc).

And I'm definitely with wvmarle here.

A very real danger is that the obsolete tutorials on the Arduino site and others misleadingly imply that the largely ornamental "barrel jack" and "Vin" connections to the on-board regulator allow a usable source of 5 V power. This is absolutely not the case. It was essentially only for demonstration use of the bare board back in the very beginning of the Arduino project when "9V" transformer-rectifier-capacitor power packs were common and this was a practical way to power a lone Arduino board for initial demonstration purposes. And even then it was limited because an unloaded 9 V transformer-rectifier-capacitor supply would generally provide over 12 V which the regulator could barely handle.

So yes, power the pump with 12 V, obtain a 12V-5V "buck" converter and feed it with the 12 V, connect its output to the Arduino 5 V and ground, and connect its output separately to the relay 5 V and ground with the relay control wire running back along with the power wires such as to form no open loops.

Now that you have adequately powered the relay board and the Arduino, connect your sensors directly to the Arduino. We do hear questions as to how to make the multiple parallel connections needed particularly for power, the answer is that is when you need to learn to solder and why the UNO in particular is inconvenient; a Nano can (with pin headers soldered) be used in a breadboard or soldered on perfboard/ "stripboard" (Vero) for permanent use. :sunglasses:

The type of relay used in the tutorial is a poor choice. The tutorial writer does not even seem to know that different and more appropriate types of relay are available. They refer to it simply as "Relay" as though only one type exists. But it is clear from how they wired it that it is a 5V relay, which requires a large current to be supplied at 5V by the Arduino. A 12V relay, rather than the 5V relay used, would require almost no current to be supplied by the Arduino. This would have allowed the arduino to be powered by 12V through Vin. The Arduino's regulator would only have to provide current at 5V for itself and the sensor (SR04 only draw a few mA) and there would be little danger of it over heating.

Even better than a 12V relay would be a logic level MOSFET such as stp16nf06l or similar.

Replace the relay by a MOSFET - that allows you to run the Uno off 12V directly (don't put it in a box, it needs fresh air to keep cook) while having it switch the pump using that MOSFET.

Thank you very much for all your replies! Extremely helpful info.

Paul__B had described that the 5V relay is fine, as long as a 12v-5V buck converter is added.

However, PaulRB and wvmarle had described using a MOSFET instead of a 5V relay, or even a 12V relay. This would then allow the Arduino to run off 12V directly.

What is the best option? Should I use the buck converter to power the Arduino with 5V through the VIN pin? Or use a MOSFET to power the Arduino with 12V through the VIN pin? Although, the regulator on the Arduino may not be able to handle the 12V through the VIN pin.

Thanks a lot everyone!

super923kid7x7:
Although, the regulator on the Arduino may not be able to handle the 12V through the VIN pin.

That is the point. It might - or it might not - depending on the particular components, the actual voltage and what else you decide to connect now or at a future date.

The "buck converter" will always be the safest and most reliable way to power your Arduino from 12 V.

Paul__B:
The "buck converter" will always be the safest and most reliable way to power your Arduino from 12 V.

Thanks again! Would this type of converter work in my case?
12V - 5V Converter

super923kid7x7:
Thanks again! Would this type of converter work in my case?
12V - 5V Converter

That looks like a singularly durable specimen, easily able to cope with the relay module and many other attachments as well. You could find a much more inexpensive module to do the same.

Note still my advice in the third and fourth paragraphs of #6. :sunglasses:

For switching loads I strongly prefer using solid state switches (i.e. MOSFETs for DC loads) over relays. Smaller, cheaper, easier to control, no noise. Though a relay will do just fine, and if you have one already, just go for it. Getting a project working should always be the first priority after which you can try to improve on things.

That power supply you link to is pretty beefy indeed. Nice case. Much cheaper options are available for sure, as in 1-2 USD or so for a 2-3A rated unit, but you do get a barebones PCB to which you have to solder your own wires, no case. I wouldn't want to load those cheap made-in-China ones for more than about half their rating, though you need only some 200 mA so no problem there.

The simplest circuit would be to power the Arduino with 12V through Vin or the barrel connector and use a mosfet to switch the pump. As long as you keep the current drawn at 5V low, perhaps no more than 70~80mA, the regulator should cope. If you put the arduino in a box, some ventilation holes would be a good idea. If that is a problem because it needs to be weatherproof, then your SR04 is also a problem. But you can get weather proof ultrasonic sensors.

Choice of Arduino can also help here. A Pro Mini draws less current than an Uno, for example. Come to that, a Digispark might be adequate for your project!

If using a mosfet, don't forget to connect a "flyback" diode (e.g. 1N4001) across the pulp terminals (cathode to 12V).