Use a Transistor or MOSFET as a switch to control Solenoid

I am working on a project to control a Solenoid (12 V/DC 12.96 W) with ESP32. I have attached circuit design as it is in picture. I have couple of questions:

Would this circuit work properly?
Do I need to change the Transistor (PN2222) to a MOSFET (IRLB8743PBF)?
Solenoid Force varies between 30N,59N. How can i control the force of Solenoid via ESP32?

Thank you in advance
Yakup

Shoot

But I would say a little Googling will give you all the answers quicker...

But uhhhh, why is the 12V connected to a pin labeled 5V? And if that relay is really 12W it's quite a beast. A poor old 2222 can't supply that 1A. Switch to a logic level mosfet. But again, I'm repeating Google.

Hi,
I tried google almost a month, but couldn't get any proper answer to be honest. ESP32 has voltage regulator built-in and it regulates up to 12v.

But thanks anyway :slight_smile:

Could you provide links to the ESP32 module you're using, and the solenoid too?

I have no experience with the ESP32, but perhaps someone else can say whether you can apply 12V to a pin labeled 5V.

There are at least a squillion different esp32 boards so we need to know which you are using.

ESP32 has voltage regulator built-in and it regulates up to 12v.

Not on a 5V pin. Perhaps on your board there is a Vin going to a regulator.

Anyway its not good practice to use a 12V supply to power a switched inductive high current device AND a microprocessor. I'd recommend an external regulator and decoupling caps everywhere.

yakuparslan72:
I am working on a project to control a Solenoid (12 V/DC 12.96 W) with ESP32. I have attached circuit design as it is in picture. I have couple of questions:

Would this circuit work properly?

You have a solenoid needing 12V and over 1A. You are trying to power it from the ESP's 5V pin using a transistor rated for 0.6A.

So no, clearly isn't going to work well.

I'd strongly suggest use a separate supply for the microcontroller and the solenoid - heavy current inductive
loads are not friendly to logic chips.

A logic-level MOSFET is needed, the IRLB8743 you suggest will be fine.

Remember to decouple the 12V supply near the MOSFET. A 10--100uF electrolytic or so would be a plausible
value. This will reduce noise spikes significantly - together with the free-wheel diode.

[ BTW the high 1k base resistor in your circuit would have limited the 2N2222 to about 150mA
loads anyway - compute base current as 5 to 10% of collector current for a BJT used for
switching ]

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.