Hello i want to switch electric door lock (12V, 170mA) with esp32(3.3V). If is it possible I want use tranzistor. I tried to use IRF520, but it only worked with 5V. My sugestion is use 2 tranzistors one would switch 5V to IRF520 which would switch 12V. Can someone pro provide me some schematic, how to solve it? Thanks.
BC549 provides strong pull-down for IRFR5305, which is provides up to +12V at 16A with less than 0.09 Ohm channel resistance.
This circuit works well with ESP8266, I use it in some of my devices.
A single, reasonably tough general purpose BJT is all you need here if you really want a simple solution. The 2N4401 supports up to 600mA of current and has a 40V Vce max. As long as the solenoid on the door lock has a snubber it doesn't need to be any more complicated than this unless you need isolation or have other constraints.
Note that below I've drawn a relay because it was easy, but you can just as well put your door lock's solenoid coil where the relay is drawn below (they're effectively the same type of device).
I have exactly this setup on an ESP8266 controlling a 24V relay and it works great. I'm using an old 2N2222, which are long since obsolete, but the 2N4401 would do just the same.