-->
Page 1 of 1

Driving a MOSFET using ESP-01 - Need Help

PostPosted: Tue Sep 07, 2021 2:33 am
by Amorphous
I am trying to drive a MOSFET using ESP-01 to control 12V supply. Schematic is attached. Here is my simple code -

Code: Select all#include <ESP8266WiFi.h>

#define MOSFET 2
#define SWITCH 0
#define DEBUG True


void setup() {
 
  pinMode(SWITCH, INPUT);     // Initialize the GPIO2 pin as an output
  pinMode(MOSFET, OUTPUT);
  digitalWrite(MOSFET, HIGH);
}

void loop() {

  digitalWrite(MOSFET,HIGH);
 
  // put your main code here, to run repeatedly:

}


But its not switching. What am I doing wrong? Pls help

Re: Driving a MOSFET using ESP-01 - Need Help

PostPosted: Fri Sep 10, 2021 11:36 am
by Michaelo
You should be able to drive the MOSFET directly via a 10k current limiting resistor to its Gate?

The Gate Threshold Voltage (Vgs(th)@Id) : 3V 250uA...
Drain Source On Resistance (RDS(on)@Vgs,Id) : 0.009Ω 30A,10V

What's happening with the current circuit?

Re: Driving a MOSFET using ESP-01 - Need Help

PostPosted: Sat Sep 11, 2021 3:39 am
by schufti
with a 10k resistor the gate (dis)charges much to slowly and mosfet will slowly pass through linear region, causing lots of powerdissipation -> defect.
for mosfets and digital signal you want the gatecurrent as high as possible. So for 3.3V and Igpio (max) 10mA you want 330Ohm resistor in series with the gate.

Re: Driving a MOSFET using ESP-01 - Need Help

PostPosted: Sat Sep 11, 2021 7:02 pm
by Michaelo
First get it working, then you can discuss the gate resistor...

Having said that, I admit 10k is a little high but were only switching milliamps, nothing will be damages...