I have a 12V battery.
I want to take 3.3V from it for my ESP32 Microcontroller. I also want to take the remaining voltage (say 8.7V) for my motor driver to drive motors.
How can I achieve that without purchasing expensive components?
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
The easiest way for a hobbyist to do this is to purchase one or more buck regulator modules that use a switchmode regulator chip to reduce the voltage without much loss. Then use the 12V for the motor with PWM. You could also use a second regulator for the motor, but the rating should accommodate the maximum current the motor draws briefly when starting (eg. stall current). For example, regulators based on XLSemi's XL4016 can typically handle several amperes.
You can find larger modules capable of an ampere to several amperes with adjustment potentiometers on Amazon etc. Naturally you would adjust the output voltage before you connect the load.
It would be prudent to add a fuse and reverse battery protection.
You could also purchase the chips used and add inductors and so on, but this kind of chip is sensitive to layout and I doubt you'd save any money.
You can use relatively cheap components. So-called voltage regulators are quite ubiquitous.
They come in two main types. Assuming that your microcontroller does not draw much current you can use a linear regulator to get 3.3V. This is the simple low-power type.
I think the ESP32 draws short bursts of current when communicating over Wi-Fi. If it resets when transmitting, add more capacitance to stabilize the 3.3V.
For your motors you could use a switching regulator, but it's even better if you can use 12V to power your motors, for example by using PWM to decrease the average current. When you control a motor with PWM this actually makes the motor into its own switching regulator.
I cannot recommend specific parts. If you just search for e.g. "3.3V linear regulator" you will find plenty. A lot of regulators have adjustable output voltages.
Getting a voltage lower than the battery is simpler than a voltage greater than the battery. A voltage divider will give you a lower voltage, but the voltage will be sensitive to the load. A voltage divider with any kind of load is inefficient and wastes power.
Voltage regulators that can handle the power are more efficient. You will need to give the voltage regulators the 3.3V and 8.7V voltage reference. You can use Zener diodes for a voltage reference. You can use a potentiometer for an adjustable voltage reference. You might find voltage regulators with with the voltage reference internal. Here is a general applications note.
Switching supplies are even more efficient. Here is a tutorial.