I am trying to drive a MOSFET using ESP-01 to control 12V supply. I am programming the ESP-01 using the nodeMCU and then using the ESP-01 module connected to a 5V power supply (no arduino is connected) tp drive the MOSFET and control the 12V.

Link to PDF Schematic (more readable) - https://easyupload.io/xhfeaw

Schematic is : enter image description here

Here is my simple code -

#include <ESP8266WiFi.h>

#define MOSFET 2     //GPIO2
#define SWITCH 0     //GPIO0

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

void loop() {

  // put your main code here, to run repeatedly:

  • 1
    \$\begingroup\$ No can read schematic. \$\endgroup\$
    – Kartman
    Sep 8, 2021 at 12:07
  • \$\begingroup\$ Sorry, link to pdf - easyupload.io/xhfeaw \$\endgroup\$
    – Amorphous
    Sep 8, 2021 at 15:48
  • 1
    \$\begingroup\$ The MOSFET driving part looks OK to me. Remember that the NPN makes an inverter so making GPIO2 HIGH will turn the MOSFET (and your load) off. What is your load? Are you planning to drive inductive loads? One tip: your schematic would be more readable if you put in a proper NPN symbol. \$\endgroup\$
    – StarCat
    Sep 8, 2021 at 18:30
  • \$\begingroup\$ Thank you, I was driving it high that was the issue. Thanks for the tip as well, I will keep that in mind. Thank you for solving my problem, very grateful! :)) \$\endgroup\$
    – Amorphous
    Sep 9, 2021 at 9:07


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.