DONOFF iot light dimmer
Placed onoptocoupler circuit
The optocoupler U1 isolates the ESP-01 electronics from the lethal mains voltage. The PWM signal comes from the ESP-01 microprocessor and switches the infrared diode in U1 On and Off. When the diode is on, the emitter(4)-collector(5) transition of the transistor in U1 will conduct, causing the gate of Q1 to become > 10 volts, closing the MOSFET switch and causing the LED lamp gets voltage.