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?
Electronic – microcontroller shared power supply
esp32microcontrollerpower supply
Related Solutions
If built carefully and sensibly with shortest minimum lead lengths, short paths to power rails and proper decoupling and filtering then a breadboard can be not too much different than a PCB based supply. Good results can be expected and noise should not be vastly worse than a typical PCB based circuit.
If built as roughly as breadboard circuits often are then bad results can be expected. However, the low frequency (50 - 100 kHz MAY even save you in those cases.
Switches have a certain amount of magic in them. In some cases/locations a few pF of stray capacitance can make things go very wrong. BUT
I have successfully built numerous switchers on breadboards (plug in style).
Spec sheets say these operate at 100 kHz and 52 kHz so both are relatively "breadboard friendly".
The fixed voltage LM2575 has a slight edge in lashup-proofness as it has the critical feedback divider internally, but I'd recommend going with a variable output voltage version as being more useful and flexible and being able to teach you more. The LT part looks somewhat more capable overall.
Lower than higher frequency is liable to be more successful on a breadboard, so around 100 kHz is a good starting frequency. Old tech for most ICs. Even 1 MHz may be OK but capacitive coupling increases by 10X wrt 100 kHz. A 1 pF is 10 pF equiv. A 10 pF is 100 pF equiv. A few pF seldom hurt too much at 100 kHz.
Keep leads short. Group components together that share common heavy current paths. Bypass well. Do the best breadboard job you can. Avoid long loopy wires such as usually don't matter at all. Think ahead and plan it at least a little bit. Odds are it will work.
A trap is the feedback divider network (R1 & R2 in each case on datasheet page 1 diagram, but upper/lower swapped). Here yu have a feedback input pin and a divider from output to regulate voltage. Neither datasheet shows it, but a small capacitor across top resistor of divider (feedback ping to Vout) usually helps impulse response. A small cap from the centre point = Feedback pin to anywhere else is often a disaster. Ask me how I know :-). That MAY be most sensitive spot in many circuits.
Think about current paths. Inductor /switch/diode/filter caps (in and out), Ground and power sides.
If driving an external transistor (not relevant here) keep leads short. USe reverse zener across gate-source if using a FET.
The IC's chosen make life easy at the cost of some flexibility. For "playing" look at MC34063 - I recommend them to one and all. Old. Some defects. Cheap. capable and flexible and fun and low parts count. Built in high side current limit. Can do about ANY topology (boost, buck, buck boost, CUK, SEPIC, ... .
See figs 15, 20, 21 in datasheet for step down examples.
Fig 15 is with internal switch. Up to 0.5A out - maybe more.
Fig 20 uses NPN external but I'd use an N Channel FET.
Fig 21 uses PNP external - I'd use a P Channel FET.
I'd prefer Fig 20, with N-Channel FET.
This will do 36V + direct (40 V rated) BUT start at say 12V to 5V to play. MUCH more energy and things to go wrong at 36V in.
Ask more questions if of interest.
ADDED: 20 July (NZT)
The example ICs which have all pins in a straight line give every prospect of good results if used following the guidelines above and data sheet guidelines.
The IC can be positioned so that power rails are fed from breadboard strips only a few tenths of an inch away and decoupled with minimal lead lengths. There are few other components and these may be placed with very short leads.
However, this is such a simple circuit that use of "vectorboard"/ veroboard / ... etc copper strip board would allow a tidy and easy implementation with slightly less to go wrong.
When using plug in bread boards some component leads are so thick that they will either not fit or will permanently "set" the breadboard springs if inserted. These can be dealt with by soldering SHORT lengths of wire to them as lead extensions and plugging these into the board. Properly done and with leds trimmed the result looks OK and is liable to be effective.
Too thin wire may also have contact problems.
You are wasting quite a bit of power by using linear regulators to drop 9 V to 5 V and particularly to 3.3 V. There is also no need to run the LED from 9 V. There is no such thing as a "9 V LED". There are some packaged devices that contain a LED and resistor so that the whole thing is intended to run from some particular volage, like 9 V, 12 V, 24 V, or whatever, but then you don't have just a LED anymore.
It would be useful to know the current requirements of the 5 V circuitry, the 3.3 V circuitry, and the LED. I'm guessing that the sensor probably doesn't take much current. In that case, I'd probably use a linear regulator to make 5 V as you suggest, but a switcher to make the 3.3 V from the 9 V. The sensor runs from 5 V and everything else, including the LED, runs from 3.3 V. That will be a lot more efficient. Assuming this is a normal red, yellow, or green LED, it can be run from 3.3 V easily with the right resistor in series.
Best Answer
Yes this is perfectly fine, and in fact the normal. However a few considerations.
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.
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.
Make sure your power supply can deliver the proper voltage, current, and power. If not use a supply that can.
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.
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.
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.