5

Usually on the breadboard i power the microcontroller and then power all the other devices through the microcontroller. Now i want to move my project to an enclosure, and i'm consedering to power all the devices directly from the power supply, is this possible / correct to do?

enter image description here

nunocv
  • 125
  • 1
  • 1
  • 5

2 Answers2

3

Yes this is perfectly fine, and in fact the normal. However a few considerations.

  1. Most important. Because you are powering all your devices off a 5V line, and the ESP32 is a 3.3V device this means they can not safely talk to each other in most cases without a level line converter. Most 5V powered modules have 5V logic levels and if you feed this into a 3.3V ESP32 you are going to fry it. So make sure your logic levels are appropriate.

  2. Also important, make sure the power supply is regulated. That is, it provides the correct voltage and is well regulated. Often an external power supply may be a "dirty" power supply and expects on-board regulation. This also has the advantage of allowing you to connect a different power supply with a different voltage without frying everything. So consider if you want an on-board LDO regulator to regulate your power supply voltage.

  3. Make sure your power supply can deliver the proper voltage, current, and power. If not use a supply that can.

  4. Most power supplies have a large "Tank" capacitor to eliminate ripple. More power draw means you need a bigger capacitor, pick one appropriately. The tank should be on your own PCB, the closer to the circuit the better.

  5. Regardless of the capacitor used in point #4 there must be additional bypass/decoupling capacitors across the power terminals of each of the ICs in your circuit.

  6. If you are going to use a well regulated external supply and not include an on board voltage regular, that is fine but make sure you have the tank capacitor mentioned in point #4 and also consider adding over-voltage protection in the event someone hooks up the wrong external power supply with either reverse voltage or a higher voltage than expected.

One note of warning, when you said you normally power devices off your microcontroller I hope you meant the +3.3V pin on an ESP32 board (that would be fine) and not from the logic output pins of the \$\mu C\$ itself. The logic output pins arent really intended to deliver much power and you can easily overload the microcontroller by doing this.

With that said powering off the +3.3V line of an ESP32 main board would make more sense, usually, than powering off the external power supply itself just because it is going to be a regulated power supply so prevents you from needing to add another regulator. Though if the ESP32 cant provide the power you need then providing an additional external power supply is not an issue. Just make sure the ground pins of the ESP32 and the new external power supply are electrically connected as well if you do that.

  • @nunocv Happy to help. Dont forget to upvote helpful answers and accept the answer you feel is best. – Jeffrey Phillips Freeman Sep 07 '20 at 12:01
  • Thanks to all for your tips, the power supply i plan on using is a phone charger, i'm just going to take off the case and solder it according to my needs. I'm pretty sure is well regulated and "safe". The esp32 have a Vin pin on which one can power the board with the 5v, as this pin is the same as if it was connected with the usb port. When i said about power the other devices, it was using the vcc pin on the esp32, i know the gpio are not for powering purposes. I did not understand about the capacitors, can you explain? – nunocv Sep 07 '20 at 12:45
  • @nunocv Basically put a 1 or 10 uF capacitor across the power rails. Also dont forget to pay attention to my other more important points. – Jeffrey Phillips Freeman Sep 07 '20 at 12:51
  • @JPF the uC and the other modules all can be safelly powered with 5v. The capacitor is mandatory? I'm not an electronic expert, please don't be bothered by my questions. – nunocv Sep 07 '20 at 13:27
  • 1
    The capacitor isnt about changing the DC voltage level. It is to help keep the voltage constant. For example if you suddenly drew power the voltage could drop slightly and this can cause errors in your hardware. It also helps to remove noise on your power lines. So is it mandatory.. no, if you dont use it there is a good chance things might work some of the time.. but its a really good idea and will ensure your device works under less than ideal conditions. – Jeffrey Phillips Freeman Sep 07 '20 at 13:29
  • Ok, you suggested a capacitor of 1 or 10uF, i have access to both, which one you think is better? – nunocv Sep 07 '20 at 14:03
  • @nunocv it wont make a huge difference but I usually go with 10uF – Jeffrey Phillips Freeman Sep 07 '20 at 14:07
1

Just to add to the other answer. Actually, powering different devices from the same source is the normal thing, while powering them from the uC must have some valid reason. The only valid reason I can think of is: you can turn off the device during normal operation, under the control of software. Some devices can be turned off anyway by software (using pins like sleep, enable, or so).

Normally, uCs have a limit on the output current of any single output pin, and a limit on the total current (sum of all the outputs).

Then, you are talking about ESP32, which is not simply an MCU but a module (a set of devices); I seem to remember it has power supply output pins which are not GPIOs but something more powerful (and not controllable). In this case, it could be a good idea to use them, but it could be not.

Anyway, as stated in the other answer, decoupling capacitor are important, in all the cases.

  • I have a feeling when he said he powered it off the microcontroller he might have actually meant the +5V pin from an arduino and not from one of the logic outputs of the IC.. at least, I really hope thats what he meant. I will add your caution to my own answer though, thanks. – Jeffrey Phillips Freeman Sep 07 '20 at 05:50
  • 1
    @JeffreyPhillipsFreeman you're welcome. – linuxfan says Reinstate Monica Sep 07 '20 at 05:52
  • I'm not an electronic expert. Should i be learning about decoupling capacitor? In your opinion is it important when dealing with microcontrollers projects? – nunocv Sep 07 '20 at 13:31
  • 1
    @nunocv usually every *chip* needs a 100 nF capacitor associated. Modules (like the esp32) are different, they can already contain one (but who knows?). Your "4-channel relays" could inject a lot of noise on the +5V (or maybe not, it depends). BUT: decoupling is important; easy and fast to learn; don't miss it. – linuxfan says Reinstate Monica Sep 07 '20 at 14:30
  • @linuxfansaysReinstateMonica should it be done with ceramic or electrolytic capacitor? i do have electrolytic capacitor at hand and the smallest value i have is 1uF, is this ok? – nunocv Sep 09 '20 at 01:57
  • @nunocv ceramic and electrolytic serve different purposes. The first decouples (typical 100 nF), the second is a bigger storage but slower. Typically, use a 100 nF ceramic near every "digital chip", and one, shared, electrolytic (say, from 100 uF up to several thousands) for every different power supply (+3.3, +5, +12, +24 and so on). But I advise to post a new question with a basic schematic in it asking about caps - what kind and where to place. – linuxfan says Reinstate Monica Sep 09 '20 at 06:05