A few seconds after... I got smoke on the servo (sg90) and burn smell on the esp32-cam. Both are dead now.
I'm fairly new to this so I'm trying to understand what happened.
I imagine the issue was the high voltage of the power supply which was too high for the servo?
How was I supposed provide supply to the servo?
Why did the ESP32 CAM burned? I read that providing 12V to the its 5V pin would be ok since the ESP would regulate the voltage down?
Servos are usually rated for 4.8-6V, and they need a separate power supply. A 4xAA battery pack works well for 1-2 small servos. Don't forget to connect all the grounds.
Power the ESP32-CAM with a regulated power supply, either 5V or 3.3V, capable of at least 500 mA.
Absolutely not. Servos draw huge amounts of current, compared to MCUs, and inject very damaging voltage spikes and electrical noise into their power supplies.
That is why wise experimenters always use separate power supplies for motors, servos and solenoids.
The companies that make such products hire highly trained engineers, who know how to design such circuits and make them work reliably. Typically four to six years of higher education, along with further professional experience is required.