12V volts being reduced through a PN2222
The drive should look like this: 







simulate this circuit &ndash; Schematic created using CircuitLab

I have reduced the base resistor value to allow driving a fan of >200mA. If your fan is only 50mA or less the 1K is fine. D1 is to absorb any inductive spike from the fan motor when the transistor turns off.  

Note the ground connection between the ESP and the power supply.