I am working on a project to start a vehicle using Automotive Relays. And I am following this circuit in the tutorial to do so. Everything works fine on Arduino UNO. But I want to use ESP32 of this kind in my final project and ESP32 is 3.3v with ~12mA max current. When I plug ESP32 to the above-given circuit (Obviously powering through external 5v connection with the shared ground and not 12v battery), it fails to trigger the relay and instead resets. Any suggestions?
The ESP board has 5V in but runs on 3.3V, has a small ldo on the board to regulate the 5V down. And as the output current rises the output voltage level will drop below 3.3V.
The solution is to replace the TIP NPN Darlington transistor with a logic level N-Channel mosfet. IRLZ44 or STN4NF03L maybe. These are voltage driven instead of current driven and won't have the issues with the ESPs limited current and sagging voltage output.
Alternatively, use a opto isolated relay board/module. The esp would drive a small led based optocoupler that then drives a transistor and the relay.
Or use a smaller relay. Or use a small nfet to drive your Darlington transistor. A bunch of options. The logic level mosfet would be the simplest imho.
I would recommend using a logic level MOSFET. Use 1k gate resistance and don't forget to add a pull-down resistor (10k or so) so that the MOSFET remains OFF when you want it to be OFF ;) Make sure your GPIO pin voltage is at acceptable levels with the pull-down resistor installed. You'll find more details about this in the microcontroller datasheet.