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
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() {
digitalWrite(MOSFET,HIGH);
// put your main code here, to run repeatedly:
}